24
1
Fork 0

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
//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,

View File

@ -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({