Client portal: profile, activity pages + middleware fix
This commit is contained in:
+4
-1
@@ -3,6 +3,8 @@ import type { NextRequest } from "next/server"
|
||||
|
||||
const publicRoutes = [
|
||||
"/login",
|
||||
"/client-portal/login",
|
||||
"/client-portal/api",
|
||||
"/api/auth/login",
|
||||
"/api/auth/logout",
|
||||
"/_next/static",
|
||||
@@ -29,7 +31,8 @@ export async function middleware(request: NextRequest) {
|
||||
if (pathname.startsWith("/api/")) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
|
||||
}
|
||||
const loginUrl = new URL("/login", request.url)
|
||||
const loginPath = pathname.startsWith("/client-portal") ? "/client-portal/login" : "/login"
|
||||
const loginUrl = new URL(loginPath, request.url)
|
||||
loginUrl.searchParams.set("redirect", pathname)
|
||||
return NextResponse.redirect(loginUrl)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user