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

25 lines
605 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',
2020-02-13 19:52:20 +08:00
'Authorization',
2020-02-18 00:07:26 +08:00
'Carto-Event',
'Carto-Event-Source',
'Carto-Event-Group-Id'
];
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
2019-10-22 01:07:24 +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
};