add cors for upload endpoint only
This commit is contained in:
parent
36cc7470be
commit
ae7cec342e
1 changed files with 2 additions and 5 deletions
7
index.js
7
index.js
|
@ -73,15 +73,11 @@ const corsOptions = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use('*', cors(corsOptions));
|
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
// res.render('upload');
|
// res.render('upload');
|
||||||
res.redirect(config.url);
|
res.redirect(config.url);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.get('/file/:filename', (req, res) => {
|
app.get('/file/:filename', (req, res) => {
|
||||||
const filename = req.params.filename;
|
const filename = req.params.filename;
|
||||||
const filePath = path.join(config.storagePath, 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 password = req.body.password;
|
||||||
const chosenFileName = req.body.filename;
|
const chosenFileName = req.body.filename;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue