add cors for upload endpoint only

This commit is contained in:
hippoz 2020-10-05 00:31:23 +03:00
parent 36cc7470be
commit ae7cec342e

View file

@ -73,15 +73,11 @@ const corsOptions = {
}
}
app.use('*', cors(corsOptions));
app.get('/', (req, res) => {
// res.render('upload');
res.redirect(config.url);
});
app.get('/file/:filename', (req, res) => {
const filename = req.params.filename;
const filePath = path.join(config.storagePath, filename);
@ -111,7 +107,8 @@ app.get('/file/:filename', (req, res) => {
});
});
app.post('/api/upload', (req, res) => {
// TODO: add cors for all endpoints
app.post('/api/upload', [ cors(corsOptions) ], (req, res) => {
const password = req.body.password;
const chosenFileName = req.body.filename;