fix: admin/options: "Links from other website" was not working correctly behind a proxy

Massimo Melina committed Sep 22, 2024 at 12:27 UTC fcaa66e8f444d21af669a9a1af579871c46b5a64
2 files changed +2 -2
src/basicWeb.ts
+1 -1
@@ -42,7 +42,7 @@ export function basicWeb(ctx: Koa.Context, node: VfsNode) {
42 stream.push(`<title>${title.get()}</title><body>`)
43 stream.push(getSection('basicHeader'))
44 const u = getCurrentUsername(ctx)
45 - const links: Dict<string> = u ? { [`//LOGOUT%00:@${ctx.get('host')}/?get=logout`]: `Logout (${u})` } : { '/?get=login': "Login" }
45 + const links: Dict<string> = u ? { [`//LOGOUT%00:@${ctx.host}/?get=logout`]: `Logout (${u})` } : { '/?get=login': "Login" }
46 stream.push(_.map(links, (v,k) => a(k, v)).join(' ') + '\n<ul>\n')
47 if (ctx.state.originalPath.length > 1)
48 stream.push('<li>' + a('..' + force, '..') + '\n')
src/serveFile.ts
+1 -1
@@ -45,7 +45,7 @@ export async function serveFileNode(ctx: Koa.Context, node: VfsNode) {
45 await limitDownloads(ctx) || await limitDownloadsPerIp(ctx)
46
47 function host() {
48 - const s = ctx.get('host')
48 + const s = ctx.host
49 return s[0] === '[' ? s.slice(1, s.indexOf(']')) : s?.split(':')[0]
50 }
51 }