|
|
|
@ -2,7 +2,6 @@
|
|
|
|
|
|
|
|
|
|
const os = require('os');
|
|
|
|
|
const winston = require('winston');
|
|
|
|
|
const nconf = require('nconf');
|
|
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
|
|
|
|
const meta = require('../meta');
|
|
|
|
@ -35,7 +34,6 @@ module.exports = function (middleware) {
|
|
|
|
|
|
|
|
|
|
if (origins.includes(req.get('origin'))) {
|
|
|
|
|
headers['Access-Control-Allow-Origin'] = encodeURI(req.get('origin'));
|
|
|
|
|
headers.Vary = headers.Vary ? `${headers.Vary}, Origin` : 'Origin';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -54,15 +52,10 @@ module.exports = function (middleware) {
|
|
|
|
|
originsRegex.forEach(function (regex) {
|
|
|
|
|
if (regex && regex.test(req.get('origin'))) {
|
|
|
|
|
headers['Access-Control-Allow-Origin'] = encodeURI(req.get('origin'));
|
|
|
|
|
headers.Vary = headers.Vary ? `${headers.Vary}, Origin` : 'Origin';
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!headers.hasOwnProperty('Access-Control-Allow-Origin')) {
|
|
|
|
|
headers['Access-Control-Allow-Origin'] = nconf.get('url');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (meta.config['access-control-allow-credentials']) {
|
|
|
|
|
headers['Access-Control-Allow-Credentials'] = meta.config['access-control-allow-credentials'];
|
|
|
|
|
}
|
|
|
|
|