dynamic domain fix

This commit is contained in:
Brian Emilius
2020-10-01 13:22:54 +02:00
parent 72808d662c
commit 1a287db553
3 changed files with 20 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ async function createSingleAsset(req, res, next) {
try {
let file = saveFile(req.files.file);
let asset = await Asset.create({
url: "https://be-dyrevelfaerd.herokuapp.com/file-bucket/" + file
url: process.env.APP_DOMAIN + "/file-bucket/" + file
});
res.json(asset);
} catch (error) {
@@ -34,8 +34,22 @@ async function getSingleAsset(req, res, next) {
}
}
async function updateSingleAsset(req, res, next) {
try {
let asset = await Asset.findByPk(req.params.id);
asset.update({
url: req.fields.url
});
res.json(asset);
} catch(error) {
console.error(error);
res.status(500).end();
}
}
module.exports = {
createSingleAsset,
getAllAssets,
getSingleAsset
getSingleAsset,
updateSingleAsset
};