Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLeitwolf112026-10-23 11:41:06 +0300
committerLeitwolf112026-10-23 11:41:06 +0300
commit85bdf1aba26641bf90da84fd6ce642ac41a6e73e (patch)
tree603c9323bbd1e7706f9d0b9dc0953f42b1809727
parent6e871a697f64d3460e838bff19a52637faf22f08 (diff)
downloadprogmaweb-feature/progmasoft-site.tar.gz
Let the second proxy pass through a site's own treefeature/progmasoft-site
The standalone server, which production runs, invokes the proxy again for the rewritten path with the original host. A path already inside the site's internal tree (/authorize/signin on authorize.progmasoft.com) did not match the public routes and became the site's not-found page, so every OAuth, console and product page answered 404 in production while next start, which runs the proxy once, served them. A path under the site's own root now passes unchanged; internal trees stay closed on every other host. Checked against the standalone build for all hosts.
-rw-r--r--apps/web/proxy.ts6
1 files changed, 6 insertions, 0 deletions
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"));