fix: bypass proxy for same-origin 3d assets
This commit is contained in:
parent
132af95df9
commit
90e56b7dde
@ -16,12 +16,27 @@ const PROXY_HOST_KEYWORDS = [
|
||||
"cloudfront.net",
|
||||
];
|
||||
|
||||
function isSameOriginBrowserAssetUrl(raw: string) {
|
||||
if (typeof window === "undefined") return false;
|
||||
|
||||
try {
|
||||
const parsed = new URL(raw, window.location.origin);
|
||||
return parsed.origin === window.location.origin;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function shouldProxyThreeAssetUrl(value?: string | null) {
|
||||
const raw = String(value || "").trim();
|
||||
if (!raw || raw.startsWith("/") || raw.startsWith("blob:") || raw.startsWith("data:")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isSameOriginBrowserAssetUrl(raw)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = new URL(raw);
|
||||
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user