From dff02672392632a05ffa5e47e3c49965fb7fc156 Mon Sep 17 00:00:00 2001 From: Hagay Goshen Date: Fri, 22 Nov 2024 12:14:34 +0200 Subject: [PATCH] fix: cloudcmd: make manifest.json accessible when authentication is enabled (#428) * Make manifest.json accessable when authentication is enabled * add test for manifest.json availability when authentication is enabled --- html/index.html | 2 +- {static => public}/manifest.json | 0 server/auth.js | 2 +- server/cloudcmd.spec.mjs | 17 +++++++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) rename {static => public}/manifest.json (100%) diff --git a/html/index.html b/html/index.html index 353d6a83..0c374b9c 100644 --- a/html/index.html +++ b/html/index.html @@ -9,7 +9,7 @@ - + diff --git a/static/manifest.json b/public/manifest.json similarity index 100% rename from static/manifest.json rename to public/manifest.json diff --git a/server/auth.js b/server/auth.js index 60a3fda5..39b78c9c 100644 --- a/server/auth.js +++ b/server/auth.js @@ -17,7 +17,7 @@ module.exports = (config) => { function _middle(config, authentication, req, res, next) { const is = config('auth'); - if (!is) + if (!is || req.originalUrl.startsWith("/public/")) return next(); const success = () => next(); diff --git a/server/cloudcmd.spec.mjs b/server/cloudcmd.spec.mjs index 96b865b4..9fc4ce71 100644 --- a/server/cloudcmd.spec.mjs +++ b/server/cloudcmd.spec.mjs @@ -178,3 +178,20 @@ test('cloudcmd: sw', async (t) => { t.equal(status, 200, 'should return sw'); t.end(); }); + +test('cloudcmd: manifest.json', async (t) => { + const config = { + auth: true, + }; + + const options = { + config, + }; + + const {status} = await request.get('/public/manifest.json', { + options, + }); + + t.equal(status, 200, 'should return manifest.json even when authentication is enabled'); + t.end(); +});