test: x-forwarded-proto

This commit is contained in:
DIYgod 2023-10-21 16:16:06 +08:00
parent 9a495cdaaf
commit 31d9aa67ae
No known key found for this signature in database
2 changed files with 7 additions and 6 deletions

View File

@ -19,9 +19,7 @@ data:
dns cloudflare {env.CF_API_TOKEN}
}
reverse_proxy xlog-internal.crossbell.svc:3000 {
header_up x-forwarded-proto http
}
reverse_proxy xlog-internal.crossbell.svc:3000
}
:8080 {
@ -33,9 +31,7 @@ data:
on_demand
}
reverse_proxy xlog-internal.crossbell.svc:3000 {
header_up x-forwarded-proto http
}
reverse_proxy xlog-internal.crossbell.svc:3000
}
---
apiVersion: v1

View File

@ -17,6 +17,11 @@ export default async function middleware(req: NextRequest) {
requestHeaders.set("x-xlog-search", req.nextUrl.search)
requestHeaders.set("x-xlog-ip", getClientIp(req) || "")
console.log(
`x-forwarded-proto: ${req.headers.get(
"x-forwarded-proto",
)}, cf-visitor: ${req.headers.get("cf-visitor")}`,
)
if (
IS_PROD &&
req.headers.get("x-forwarded-proto") !== "https" &&