fix(admin): persist data directory and pass env vars
This commit is contained in:
parent
99e8201745
commit
1d7e7c41c9
39 changed files with 1297 additions and 32 deletions
20
proxy.ts
Normal file
20
proxy.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { NextResponse, type NextRequest } from "next/server";
|
||||
|
||||
const adminSessionCookie = "fs_admin_session";
|
||||
|
||||
export function proxy(request: NextRequest) {
|
||||
const { pathname } = request.nextUrl;
|
||||
if (!pathname.startsWith("/admin") || pathname === "/admin/login") return NextResponse.next();
|
||||
|
||||
if (!request.cookies.get(adminSessionCookie)?.value) {
|
||||
const loginUrl = new URL("/admin/login", request.url);
|
||||
loginUrl.searchParams.set("next", pathname);
|
||||
return NextResponse.redirect(loginUrl);
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/admin/:path*"],
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue