CORS added
This commit is contained in:
parent
46c9027bdb
commit
301e36b5c4
37
lib/api/CORS.js
Normal file
37
lib/api/CORS.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
module.exports = function (req, res, next) {
|
||||||
|
let allowed = {
|
||||||
|
|
||||||
|
origins: [
|
||||||
|
'*',
|
||||||
|
],
|
||||||
|
|
||||||
|
methods: [
|
||||||
|
'HEAD',
|
||||||
|
'GET',
|
||||||
|
'POST',
|
||||||
|
'PUT',
|
||||||
|
'DELETE',
|
||||||
|
'OPTIONS',
|
||||||
|
],
|
||||||
|
|
||||||
|
headers: [
|
||||||
|
'Content-Type',
|
||||||
|
'Authorization',
|
||||||
|
'Content-Length',
|
||||||
|
'X-Requested-With',
|
||||||
|
'Cache-Control',
|
||||||
|
'X-Accept-Version',
|
||||||
|
'x-signature',
|
||||||
|
'x-pubkey',
|
||||||
|
'x-identity',
|
||||||
|
'cf-connecting-ip',
|
||||||
|
],
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
res.header('Access-Control-Allow-Origin', allowed.origins.join());
|
||||||
|
res.header('Access-Control-Allow-Methods', allowed.methods.join());
|
||||||
|
res.header('Access-Control-Allow-Headers', allowed.headers.join());
|
||||||
|
|
||||||
|
next();
|
||||||
|
};
|
||||||
@ -3,6 +3,9 @@ const config = require('../../config');
|
|||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const api = express.Router();
|
const api = express.Router();
|
||||||
|
const CORS = require('./CORS');
|
||||||
|
|
||||||
|
app.use(CORS);
|
||||||
|
|
||||||
// Serve insight ui front end from root dir public folder
|
// Serve insight ui front end from root dir public folder
|
||||||
app.use('/', express.static('./public'));
|
app.use('/', express.static('./public'));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user