diff --git a/server/routes/upload.js b/server/routes/upload.js index 7f16410a..023b83a9 100644 --- a/server/routes/upload.js +++ b/server/routes/upload.js @@ -28,8 +28,7 @@ module.exports = async function(req, res) { //this hasn't been updated to expiration time setting yet //if you want to fallback to this code add this await storage.set(newId, fileStream, meta, config.default_expire_seconds); - const protocol = config.env === 'production' ? 'https' : req.protocol; - const url = `${protocol}://${req.get('host')}/download/${newId}/`; + const url = `${config.deriveBaseUrl(req)}/download/${newId}/`; res.set('WWW-Authenticate', `send-v1 ${meta.nonce}`); res.json({ url, diff --git a/server/routes/ws.js b/server/routes/ws.js index b378f383..30be0248 100644 --- a/server/routes/ws.js +++ b/server/routes/ws.js @@ -65,8 +65,7 @@ module.exports = function(ws, req) { nonce: crypto.randomBytes(16).toString('base64') }; - const protocol = config.env === 'production' ? 'https' : req.protocol; - const url = `${protocol}://${req.get('host')}/download/${newId}/`; + const url = `${config.deriveBaseUrl(req)}/download/${newId}/`; ws.send( JSON.stringify({