feat: use x-forwarded-host

This commit is contained in:
DIYgod 2023-08-23 03:08:53 +01:00
parent f4512803d8
commit 9d156cc520
No known key found for this signature in database
2 changed files with 8 additions and 4 deletions

View File

@ -20,7 +20,6 @@ data:
}
reverse_proxy xlog-internal.crossbell.svc:3000 {
header_up host {host}
header_up x-forwarded-proto http
}
}
@ -35,7 +34,6 @@ data:
}
reverse_proxy xlog-internal.crossbell.svc:3000 {
header_up host {host}
header_up x-forwarded-proto http
}
}

View File

@ -45,7 +45,10 @@ export default async function middleware(req: NextRequest) {
pathname === "/atom.xml" ||
pathname === "/feed/xml"
) {
return NextResponse.redirect(`https://${req.headers.get("host")}/feed`, 301)
return NextResponse.redirect(
`https://${req.headers.get("x-forwarded-host")}/feed`,
301,
)
}
console.debug(`${req.method} ${req.nextUrl}`)
@ -72,7 +75,10 @@ export default async function middleware(req: NextRequest) {
try {
tenant = await (
await fetch(
new URL(`/api/host2handle?host=${req.headers.get("host")}`, req.url),
new URL(
`/api/host2handle?host=${req.headers.get("x-forwarded-host")}`,
req.url,
),
)
).json()
} catch (error) {