From ae7cec342ed755f3b9a3e352068e66bea92986cd Mon Sep 17 00:00:00 2001 From: hippoz Date: Mon, 5 Oct 2020 00:31:23 +0300 Subject: [PATCH] add cors for upload endpoint only --- index.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 02ba99f..d7fb99c 100644 --- a/index.js +++ b/index.js @@ -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;