flosight-api/lib/api/CORS.js
2017-08-10 17:56:57 -04:00

38 lines
689 B
JavaScript

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();
};