diff --git a/api/src/middlewares/TestClient.ts b/api/src/middlewares/TestClient.ts
index f93d0b3a..75fdf650 100644
--- a/api/src/middlewares/TestClient.ts
+++ b/api/src/middlewares/TestClient.ts
@@ -8,6 +8,20 @@ export default function TestClient(app: Application) {
const assetCache = new Map<string, { response: FetchResponse; buffer: Buffer }>();
const indexHTML = fs.readFileSync(path.join(__dirname, "..", "..", "client_test", "index.html"), { encoding: "utf8" });
+ var html = indexHTML;
+ const CDN_ENDPOINT = (Config.get().cdn.endpointClient || Config.get()?.cdn.endpoint || process.env.CDN || "").replace(
+ /(https?)?(:\/\/?)/g,
+ ""
+ );
+ const GATEWAY_ENDPOINT = Config.get().gateway.endpointClient || Config.get()?.gateway.endpoint || process.env.GATEWAY || "";
+
+ if (CDN_ENDPOINT) {
+ html = html.replace(/CDN_HOST: .+/, `CDN_HOST: \`${CDN_ENDPOINT}\`,`);
+ }
+ if (GATEWAY_ENDPOINT) {
+ html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: \`${GATEWAY_ENDPOINT}\`,`);
+ }
+
app.use("/assets", express.static(path.join(__dirname, "..", "assets")));
app.get("/assets/:file", async (req: Request, res: Response) => {
@@ -52,13 +66,6 @@ export default function TestClient(app: Application) {
app.get("*", (req: Request, res: Response) => {
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 || "").replace(/(https?)?(:\/\/?)/g, "");
- const GATEWAY_ENDPOINT = Config.get()?.gateway.endpoint || process.env.GATEWAY || "";
-
- if (CDN_ENDPOINT && Config.get().cdn.endpointClient) html = html.replace(/CDN_HOST: .+/, `CDN_HOST: "${CDN_ENDPOINT}",`);
- if (GATEWAY_ENDPOINT && Config.get().gateway.endpointClient)
- html = html.replace(/GATEWAY_ENDPOINT: .+/, `GATEWAY_ENDPOINT: "${GATEWAY_ENDPOINT}",`);
res.send(html);
});
|