fix: (regression beta) faulty reverse-proxy with prefix
Massimo Melina committed
May 15, 2024 at 15:54 UTC
3fb9c65dc399dbedd19eaaa380fcc3f28f14c2d8
1 file changed
+7
-7
src/roots.ts
+7
-7
@@ -20,13 +20,6 @@ forceAddress.sub((v, { version }) => { // convert from legacy configs
20
export const rootsMiddleware: Koa.Middleware = (ctx, next) =>
21
(() => {
22
ctx.state.originalPath = ctx.path
23
- const root = roots.compiled()?.(ctx.host)
24
- if (!ctx.state.skipFilters && forceAddress.get())
25
- if (root === undefined && !isLocalHost(ctx) && ctx.host !== baseUrl.compiled()) {
26
- disconnect(ctx, forceAddress.key())
27
- return true // true will avoid calling next
28
- }
29
- if (!root || root === '/') return // not transformation is required
23
let params: undefined | typeof ctx.state.params | typeof ctx.query // undefined if we are not going to work on api parameters
24
if (ctx.path.startsWith(SPECIAL_URI)) { // special uris should be excluded...
25
if (!ctx.path.startsWith(API_URI)) return // ...unless it's an api
@@ -37,6 +30,13 @@ export const rootsMiddleware: Koa.Middleware = (ctx, next) =>
30
if (referer?.startsWith(ctx.state.revProxyPath + ADMIN_URI)) return // exclude apis for admin-panel
31
}
32
if (_.isEmpty(roots.get())) return
33
+ const root = roots.compiled()?.(ctx.host)
34
+ if (!ctx.state.skipFilters && forceAddress.get())
35
+ if (root === undefined && !isLocalHost(ctx) && ctx.host !== baseUrl.compiled()) {
36
+ disconnect(ctx, forceAddress.key())
37
+ return true // true will avoid calling next
38
+ }
39
+ if (!root || root === '/') return // not transformation is required
40
if (root === '' || root === '/') return
41
changeUriParams(v => join(root, v))
42
if (!params)