From 23ba42d36f640a816964976fc2b1b80bbf56adcf Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Fri, 4 Aug 2023 10:12:35 +0200 Subject: [PATCH] use new cors proxy --- static/index.html | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/static/index.html b/static/index.html index 8e9a309..6cc6638 100644 --- a/static/index.html +++ b/static/index.html @@ -199,12 +199,14 @@ async function runAllDeployments() { - const CorsProxy = "https://cors.bridged.cc/" + function corsProxify(url) { + return `https://slorber-cors-proxy.vercel.app/api?url=${encodeURIComponent(url)}` + } async function fetchDeploymentUrl(deployment,url) { const absoluteUrl = `${deployment.url}${url}`; - const corsProxyUrl = `${CorsProxy}${absoluteUrl}`; - const response = await fetch(corsProxyUrl); + const corsProxyUrl = corsProxify(absoluteUrl); + const response = await fetch(corsProxyUrl,{redirect: "manual"}); // Mostly for GH pages function removeDeploymentBaseUrl(str) { @@ -215,9 +217,10 @@ return str.replace(baseUrl,""); } - // cors proxy impl details :'( - const finalUrl = response.headers.get("x-final-url"); - const redirectUrl = absoluteUrl !== finalUrl ? removeDeploymentBaseUrl(new URL(finalUrl).pathname) : undefined; + const finalUrl = response.headers.get("Location") ?? url; + + // console.log({url, finalUrl}); + const redirectUrl = absoluteUrl !== finalUrl ? removeDeploymentBaseUrl(new URL(finalUrl,"https://example.com").pathname) : undefined; return { url,