mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 14:22:09 +03:00
feat(server): support reverse-proxy basePath deployment (#5992)
* feat(server): support reverse-proxy basePath deployment Adds OMNIROUTE_BASE_PATH (opt-in, empty by default) to next.config.mjs using Next.js's native basePath support so a deployment behind a reverse-proxy subpath (e.g. https://host/omniroute/) works without manual header stripping. Next.js strips the configured prefix from nextUrl.pathname before route classification, so classifyRoute() and isLocalOnlyPath() keep matching un-prefixed paths. The two hardcoded auth redirect targets in src/server/authz/pipeline.ts (root "/" -> "/dashboard" and unauthenticated dashboard -> "/login") now prefix with request.nextUrl.basePath so they stay inside the deployed subpath. Default empty basePath is a no-op for existing root-path deployments. Co-authored-by: zocomputer <help@zocomputer.com> Inspired-by: https://github.com/decolua/9router/pull/1810 * docs(env): document OMNIROUTE_BASE_PATH in .env.example + ENVIRONMENT.md; restore changelog * docs(env): document AUGGIE_BIN + CLI_AUGGIE_BIN (base-red from #5972 auggie) --------- Co-authored-by: zocomputer <help@zocomputer.com>
This commit is contained in:
committed by
GitHub
parent
f984bef4ec
commit
4e16a491a1
@@ -148,7 +148,7 @@ async function refreshDashboardSessionIfNeeded(
|
||||
}
|
||||
|
||||
function dashboardLoginRedirect(request: NextRequest, requestId: string): NextResponse {
|
||||
const response = NextResponse.redirect(new URL("/login", request.url));
|
||||
const response = NextResponse.redirect(new URL(`${request.nextUrl.basePath}/login`, request.url));
|
||||
response.cookies.delete("auth_token");
|
||||
stampRouteResponse(response, requestId, "MANAGEMENT");
|
||||
applyCorsHeaders(response, request);
|
||||
@@ -223,7 +223,9 @@ export async function runAuthzPipeline(
|
||||
const requestId = generateRequestId();
|
||||
|
||||
if (pathname === "/") {
|
||||
const response = NextResponse.redirect(new URL("/dashboard", request.url));
|
||||
const response = NextResponse.redirect(
|
||||
new URL(`${request.nextUrl.basePath}/dashboard`, request.url)
|
||||
);
|
||||
return stampRouteResponse(response, requestId, "MANAGEMENT");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user