diff --git a/config.js b/config.js index 6eb07cf8..53278139 100644 --- a/config.js +++ b/config.js @@ -88,6 +88,11 @@ for (let k in config) { if(!config.baseUrl.endsWith('/')) config.baseUrl = config.baseUrl + '/'; if(!config.uploadAppPath.endsWith('/')) config.uploadAppPath = config.uploadAppPath + '/'; +// Use baseUrl as uploadAppPath if it's not explicitly set +if(config.uploadAppPath === '/' && config.baseUrl !== '/') { + config.uploadAppPath = config.baseUrl; +} + // Load language files config.languages = { [config.defaultLanguage]: require(`./lang/${config.defaultLanguage}`) // default language diff --git a/lib/endpoints.js b/lib/endpoints.js index ca1e65d0..d9fa0845 100644 --- a/lib/endpoints.js +++ b/lib/endpoints.js @@ -70,20 +70,12 @@ config.plugins.forEach(pluginName => { }); // Upload App -app.get(`${ config.baseUrl }`, (req, res) => { - if (config.uploadAppPath !== `${ config.baseUrl }`) { - res.status(304).redirect(config.uploadAppPath); - } else { - res.send(uploadPage({ - ...pugVars, - baseUrl: config.uploadAppPath || config.baseUrl, - lang: req.translations - })); - } -}); - app.get(config.uploadAppPath, (req, res) => { - res.send(uploadPage({...pugVars, lang: req.translations})); + res.send(uploadPage({ + ...pugVars, + baseUrl: config.uploadAppPath, + lang: req.translations + })); }); // Return translations @@ -378,6 +370,10 @@ app.use(`${ config.baseUrl }files`, ); app.use((req, res, next) => { + if(req.url === '/') { + return res.redirect(config.uploadAppPath); + } + res.status(404).send(errorPage({ ...pugVars, error: 'Download bucket not found.',