mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add install mode verification
This commit is contained in:
parent
6e9998d45c
commit
ce50fa760f
7 changed files with 64 additions and 15 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { isInstallModeEnabled } from "@services/install/install";
|
||||
import { LEARNHOUSE_DOMAIN, getDefaultOrg, isMultiOrgModeEnabled } from "./services/config/config";
|
||||
import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
|
@ -16,7 +17,7 @@ export const config = {
|
|||
],
|
||||
};
|
||||
|
||||
export default function middleware(req: NextRequest) {
|
||||
export default async function middleware(req: NextRequest) {
|
||||
// Get initial data
|
||||
const hosting_mode = isMultiOrgModeEnabled() ? "multi" : "single";
|
||||
const default_org = getDefaultOrg();
|
||||
|
|
@ -30,7 +31,13 @@ export default function middleware(req: NextRequest) {
|
|||
|
||||
// Install Page
|
||||
if (pathname.startsWith("/install")) {
|
||||
return NextResponse.rewrite(new URL(pathname, req.url));
|
||||
// Check if install mode is enabled
|
||||
const install_mode = await isInstallModeEnabled();
|
||||
if (install_mode) {
|
||||
return NextResponse.rewrite(new URL(pathname, req.url));
|
||||
} else {
|
||||
return NextResponse.redirect(new URL("/", req.url));
|
||||
}
|
||||
}
|
||||
|
||||
// Dynamic Pages Editor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue