progmaweb
The site and account service of Progmasoft: a Next.js frontend and an ASP.NET Core API.
Clonegit clone https://git.progmasoft.com/progmaweb
Let the second proxy pass through a site's own tree
- Commit
85bdf1aba26641bf90da84fd6ce642ac41a6e73e- Author
- Leitwolf11 ·
- Parents
6e871a697f64
Changes
apps/web/proxy.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/web/proxy.ts b/apps/web/proxy.ts index dd47981..2842e4c 100644 --- a/apps/web/proxy.ts +++ b/apps/web/proxy.ts @@ -99,6 +99,11 @@ export function proxy(request: NextRequest) { if (site.api && pathname.startsWith("/api/")) { return NextResponse.next(); } + // The standalone server runs this proxy a second time for the rewritten + // path, with the same host: a path already in the site's tree is final. + if (pathname === site.root || pathname.startsWith(`${site.root}/`)) { + return NextResponse.next(); + } const destination = internalRoute( request, site.route(pathname) ?? `${site.root}/not-found`, @@ -108,6 +113,7 @@ export function proxy(request: NextRequest) { destination.search = request.nextUrl.search; return NextResponse.rewrite(destination); } + // The internal trees belong to their hosts only. for (const { root } of ownSites) { if (pathname === root || pathname.startsWith(`${root}/`)) { return NextResponse.rewrite(internalRoute(request, "/not-found"));