2016-01-22 00:24:48 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
module.exports = function cors(extraHeaders) {
|
|
|
|
return function(req, res, next) {
|
2019-01-10 22:55:08 +08:00
|
|
|
var baseHeaders = 'X-Requested-With, X-Prototype-Version, X-CSRF-Token, Authorization';
|
2016-01-22 00:24:48 +08:00
|
|
|
|
|
|
|
if(extraHeaders) {
|
|
|
|
baseHeaders += ', ' + extraHeaders;
|
|
|
|
}
|
|
|
|
|
|
|
|
res.header('Access-Control-Allow-Origin', '*');
|
|
|
|
res.header('Access-Control-Allow-Headers', baseHeaders);
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|
|
|
|
};
|