From 64a4d6b2bec7260e8d6f13eb40e2481670ac9f20 Mon Sep 17 00:00:00 2001 From: murdle Date: Sat, 27 Dec 2025 22:25:58 +0200 Subject: [PATCH] forgot to strip protocol --- src/api/Server.ts | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/api/Server.ts b/src/api/Server.ts index 3e6a0e3d..477787d3 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts @@ -167,18 +167,27 @@ export class SpacebarServer extends Server { // caca app.get(/^(?!\/(api|\.well-known)).*$/, async (req, res) => { let html = await fs.readFile( - path.join(PUBLIC_ASSETS_FOLDER, "index.html"), - "utf8" + path.join(PUBLIC_ASSETS_FOLDER, "index.html"), + "utf8" ); - + + const baseUrl = + Config.get().api.endpointPublic + ?.split("/api")[0] + ?.replace(/^https?:/, "") ?? ""; + + const cdnUrl = + Config.get().cdn.endpointPublic + ?.replace(/^https?:/, "") ?? ""; + html = html - .replaceAll("%BASE_URL%", Config.get().api.endpointPublic?.split("/api")[0] ?? "") - .replaceAll("%GATEWAY_URL%", Config.get().gateway.endpointPublic ?? "") - .replaceAll("%CDN_URL%", Config.get().cdn.endpointPublic ?? "") - .replaceAll("%VAPID_KEY%", Config.get().webPush.publicVapidKey ?? ""); - + .replaceAll("%BASE_URL%", baseUrl) + .replaceAll("%GATEWAY_URL%", Config.get().gateway.endpointPublic ?? "") + .replaceAll("%CDN_URL%", cdnUrl) + .replaceAll("%VAPID_KEY%", Config.get().webPush.publicVapidKey ?? ""); + res.type("html").send(html); - }); + }); this.app.use(ErrorHandler);