fix: use public origin for detail stitch images
This commit is contained in:
parent
769862cee9
commit
8fd5eae96a
@ -66,8 +66,15 @@ async function runBoundedParallel<T, R>(
|
||||
function getRequestOrigin(request: NextRequest): string {
|
||||
const forwardedHost = (request.headers.get("x-forwarded-host") || "").split(",")[0]?.trim();
|
||||
const forwardedProto = (request.headers.get("x-forwarded-proto") || "").split(",")[0]?.trim();
|
||||
if (forwardedHost && forwardedProto) {
|
||||
return `${forwardedProto}://${forwardedHost}`;
|
||||
const host = forwardedHost || (request.headers.get("host") || "").split(",")[0]?.trim();
|
||||
if (host) {
|
||||
const requestUrl = new URL(request.url);
|
||||
const isLocalHost =
|
||||
host.startsWith("localhost") ||
|
||||
host.startsWith("127.0.0.1") ||
|
||||
host.startsWith("[::1]");
|
||||
const proto = forwardedProto || (isLocalHost ? requestUrl.protocol.replace(/:$/, "") : "https");
|
||||
return `${proto}://${host}`;
|
||||
}
|
||||
return new URL(request.url).origin;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user