fix: set X-Forwarded-Host for rewrite
This commit is contained in:
parent
5a9c1115a2
commit
bc906ccb56
|
|
@ -4,7 +4,9 @@ export const APP_NAME = process.env.NEXT_PUBLIC_APP_NAME || "xLog"
|
|||
export const APP_SLOGAN =
|
||||
process.env.NEXT_PUBLIC_APP_SLOGAN || "Write. Own. Earn."
|
||||
export const OUR_DOMAIN =
|
||||
process.env.NEXT_PUBLIC_OUR_DOMAIN || process.env.NEXT_PUBLIC_VERCEL_URL
|
||||
process.env.NEXT_PUBLIC_OUR_DOMAIN ||
|
||||
process.env.NEXT_PUBLIC_VERCEL_URL ||
|
||||
"localhost:2222"
|
||||
export const SCORE_API_DOMAIN = process.env.NEXT_PUBLIC_SCORE_API_DOMAIN
|
||||
export const IMAGE_PROXY_DOMAIN =
|
||||
process.env.NEXT_PUBLIC_IMAGE_PROXY_DOMAIN || "xlog.app"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { NextRequest, NextResponse } from "next/server"
|
|||
import { getClientIp } from "@supercharge/request-ip"
|
||||
|
||||
import { IS_PROD } from "~/lib/constants"
|
||||
import { DISCORD_LINK, SITE_URL } from "~/lib/env"
|
||||
import { DISCORD_LINK, OUR_DOMAIN, SITE_URL } from "~/lib/env"
|
||||
|
||||
// HTTPWhiteListPaths: White list of path for plain http request, no HTTPS redirect
|
||||
const HTTPWhitelistPaths = ["/api/healthcheck"]
|
||||
|
|
@ -91,7 +91,7 @@ export default async function middleware(req: NextRequest) {
|
|||
requestHeaders.set("x-xlog-ip", getClientIp(req) || "")
|
||||
|
||||
if (tenant?.subdomain) {
|
||||
requestHeaders.set("X-Forwarded-Host", "")
|
||||
requestHeaders.set("X-Forwarded-Host", OUR_DOMAIN)
|
||||
return NextResponse.rewrite(
|
||||
new URL(
|
||||
`/site/${tenant?.subdomain}${pathname}${req.nextUrl.search}`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue