Windshaft-cartodb/lib/api/middlewares/cors.js

22 lines
508 B
JavaScript
Raw Normal View History

'use strict';
module.exports = function cors () {
2018-03-02 01:46:04 +08:00
return function corsMiddleware (req, res, next) {
const headers = [
'X-Requested-With',
'X-Prototype-Version',
'X-CSRF-Token',
'Authorization'
];
2018-03-02 01:46:04 +08:00
if (req.method === 'OPTIONS') {
headers.push('Content-Type');
2015-07-08 19:27:56 +08:00
}
2018-03-02 01:46:04 +08:00
2015-09-17 08:03:09 +08:00
res.set("Access-Control-Allow-Origin", "*");
res.set("Access-Control-Allow-Headers", headers.join(', '));
2018-03-02 01:46:04 +08:00
2015-07-08 19:27:56 +08:00
next();
};
2015-09-17 08:03:09 +08:00
};