Properly derive base URL as configured in file upload logic

Fixes https://github.com/timvisee/send/issues/29
This commit is contained in:
timvisee 2021-05-07 13:00:45 +02:00
parent b4b8060a78
commit 4c45d6217d
No known key found for this signature in database
GPG key ID: B8DB720BC383E172
2 changed files with 2 additions and 4 deletions

View file

@ -28,8 +28,7 @@ module.exports = async function(req, res) {
//this hasn't been updated to expiration time setting yet //this hasn't been updated to expiration time setting yet
//if you want to fallback to this code add this //if you want to fallback to this code add this
await storage.set(newId, fileStream, meta, config.default_expire_seconds); await storage.set(newId, fileStream, meta, config.default_expire_seconds);
const protocol = config.env === 'production' ? 'https' : req.protocol; const url = `${config.deriveBaseUrl(req)}/download/${newId}/`;
const url = `${protocol}://${req.get('host')}/download/${newId}/`;
res.set('WWW-Authenticate', `send-v1 ${meta.nonce}`); res.set('WWW-Authenticate', `send-v1 ${meta.nonce}`);
res.json({ res.json({
url, url,

View file

@ -65,8 +65,7 @@ module.exports = function(ws, req) {
nonce: crypto.randomBytes(16).toString('base64') nonce: crypto.randomBytes(16).toString('base64')
}; };
const protocol = config.env === 'production' ? 'https' : req.protocol; const url = `${config.deriveBaseUrl(req)}/download/${newId}/`;
const url = `${protocol}://${req.get('host')}/download/${newId}/`;
ws.send( ws.send(
JSON.stringify({ JSON.stringify({