diff --git a/src/node/proxy.ts b/src/node/proxy.ts index da430f5b3a15..35fd5d81a4d0 100644 --- a/src/node/proxy.ts +++ b/src/node/proxy.ts @@ -9,6 +9,8 @@ proxy.on("error", (error, _, res) => { }) // Intercept the response to rewrite absolute redirects against the base path. +// Is disabled when the request has no base path which means --proxy-path-passthrough has +// been enabled. proxy.on("proxyRes", (res, req) => { if (res.headers.location && res.headers.location.startsWith("/") && (req as any).base) { res.headers.location = (req as any).base + res.headers.location diff --git a/src/node/routes/pathProxy.ts b/src/node/routes/pathProxy.ts index 9554a006d290..6a6b9d29c23d 100644 --- a/src/node/routes/pathProxy.ts +++ b/src/node/routes/pathProxy.ts @@ -28,8 +28,10 @@ router.all("/(:port)(/*)?", (req, res) => { throw new HttpError("Unauthorized", HttpCode.Unauthorized) } - // Absolute redirects need to be based on the subpath when rewriting. - ;(req as any).base = `${req.baseUrl}/${req.params.port}` + if (!req.args["proxy-path-passthrough"]) { + // Absolute redirects need to be based on the subpath when rewriting. + ;(req as any).base = `${req.baseUrl}/${req.params.port}` + } proxy.web(req, res, { ignorePath: true,