fix: try to fix middleware rewrite proto

This commit is contained in:
DIYgod
2023-08-22 01:40:00 +01:00
parent bc906ccb56
commit 50c7caf3bb
3 changed files with 12 additions and 6 deletions
+4 -2
View File
@@ -19,8 +19,9 @@ data:
dns cloudflare {env.CF_API_TOKEN}
}
reverse_proxy xlog-internal.crossbell.svc:3000 {
reverse_proxy http://xlog-internal.crossbell.svc:3000 {
header_up X-Forwarded-Host {host}
header_up X-Forwarded-Proto http
}
}
@@ -33,8 +34,9 @@ data:
on_demand
}
reverse_proxy xlog-internal.crossbell.svc:3000 {
reverse_proxy http://xlog-internal.crossbell.svc:3000 {
header_up X-Forwarded-Host {host}
header_up X-Forwarded-Proto http
}
}
---
+4 -2
View File
@@ -19,8 +19,9 @@ data:
dns cloudflare {env.CF_API_TOKEN}
}
reverse_proxy xlog-internal.crossbell.svc:3000 {
reverse_proxy http://xlog-internal.crossbell.svc:3000 {
header_up X-Forwarded-Host {host}
header_up X-Forwarded-Proto http
}
}
@@ -33,8 +34,9 @@ data:
on_demand
}
reverse_proxy xlog-internal.crossbell.svc:3000 {
reverse_proxy http://xlog-internal.crossbell.svc:3000 {
header_up X-Forwarded-Host {host}
header_up X-Forwarded-Proto http
}
}
---
+4 -2
View File
@@ -50,7 +50,9 @@ export default async function middleware(req: NextRequest) {
return NextResponse.redirect(`https://${req.headers.get("host")}/feed`, 301)
}
console.debug(`${req.method} ${req.headers.get("host")}${pathname}`)
console.debug(
`${req.method} ${req.headers.get("host")}${pathname}, ${req.url}`,
)
if (
pathname.startsWith("/api/") ||
@@ -95,7 +97,7 @@ export default async function middleware(req: NextRequest) {
return NextResponse.rewrite(
new URL(
`/site/${tenant?.subdomain}${pathname}${req.nextUrl.search}`,
req.url.replace("https://", "http://"),
req.url,
),
{
request: {