This commit is contained in:
hippoz 2020-10-05 00:15:13 +03:00
parent 46b8d91c1e
commit 62409d6bcf

View file

@ -5,6 +5,7 @@ const fileUpload = require('express-fileupload');
const path = require('path');
const fs = require('fs');
const mime = require('mime-types')
const cors = require('cors');
const app = express();
@ -61,10 +62,22 @@ const getFileType = (filename) => {
return type;
};
const allowlist = ['https://files.hippoz.xyz', 'https://hippoz.xyz']
const corsOptions = {
origin: function (origin, callback) {
if (whitelist.indexOf(origin) !== -1) {
callback(null, true)
} else {
callback(new Error('Not allowed by CORS'))
}
}
}
app.use('*', cors(corsOptions));
app.get('/', (req, res) => {
res.render('upload');
// res.render('upload');
res.redirect(config.url);
});