From c66a9052745d591137e96080869e5316a41153d3 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Mon, 9 Aug 2021 20:44:41 +0200 Subject: [PATCH] :bug: fix cdn endpoint --- client_test/index.html | 2 +- src/middlewares/TestClient.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client_test/index.html b/client_test/index.html index bacc5465..1a979419 100644 --- a/client_test/index.html +++ b/client_test/index.html @@ -15,7 +15,7 @@ API_VERSION: 9, GATEWAY_ENDPOINT: `${location.protocol === "https:" ? "wss://" : "ws://"}${location.hostname}:3002`, WEBAPP_ENDPOINT: "", - CDN_HOST: `//${location.hostname}:3003`, + CDN_HOST: `${location.hostname}:3003`, ASSET_ENDPOINT: "", MEDIA_PROXY_ENDPOINT: "https://media.discordapp.net", WIDGET_ENDPOINT: `//${location.host}/widget`, diff --git a/src/middlewares/TestClient.ts b/src/middlewares/TestClient.ts index 49cae118..4ebdd010 100644 --- a/src/middlewares/TestClient.ts +++ b/src/middlewares/TestClient.ts @@ -55,8 +55,8 @@ export default function TestClient(app: Application) { res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24); res.set("content-type", "text/html"); var html = indexHTML; - const CDN_ENDPOINT = Config.get().cdn.endpoint || process.env.CDN; - const GATEWAY_ENDPOINT = Config.get().gateway.endpoint || process.env.GATEWAY; + const CDN_ENDPOINT = Config.get()?.cdn.endpoint || process.env.CDN; + const GATEWAY_ENDPOINT = (Config.get()?.gateway.endpoint || process.env.GATEWAY || "").replace(/(https?)?(:\/\/?)/g, ""); if (CDN_ENDPOINT) html = html.replace(/CDN_HOST: .+/, `CDN_HOST: "${CDN_ENDPOINT}",`); if (GATEWAY_ENDPOINT) html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: "${GATEWAY_ENDPOINT}",`);