diff --git a/js/server.js b/js/server.js index ed1a8ae420..21d9b5903a 100644 --- a/js/server.js +++ b/js/server.js @@ -93,8 +93,14 @@ function Server (configObj) { app.use("/js", express.static(__dirname)); if (config.hideConfigSecrets) { + const getErrorText = (filename) => { + return `\n\n
\n\nCannot GET /config/${filename}\n\n`;
+ };
app.get("/config/config.env", (req, res) => {
- res.status(404).send("\n\n\n\nCannot GET /config/config.env\n\n"); + res.status(404).send(getErrorText("config.env")); + }); + app.get("/config/config.js", (req, res) => { + res.status(404).send(getErrorText("config.js")); }); } diff --git a/tests/e2e/config_variables_spec.js b/tests/e2e/config_variables_spec.js index 4fb9cedd17..ebf3ba1e59 100644 --- a/tests/e2e/config_variables_spec.js +++ b/tests/e2e/config_variables_spec.js @@ -31,4 +31,19 @@ describe("config with variables and secrets", () => { const cfg = await res.json(); expect(cfg.ipWhitelist).toStrictEqual(["**SECRET_IP2**", "::**SECRET_IP3**", "**SECRET_IP1**"]); }); + + it("/config/config.env should deliver 404", async () => { + const res = await fetch(`http://localhost:${config.port}/config/config.env`); + expect(res.status).toBe(404); + }); + + it("/config/config.js should deliver 404", async () => { + const res = await fetch(`http://localhost:${config.port}/config/config.js`); + expect(res.status).toBe(404); + }); + + it("/config/basepath.js should deliver 200", async () => { + const res = await fetch(`http://localhost:${config.port}/config/basepath.js`); + expect(res.status).toBe(200); + }); });