fix: add pass thru for some subdomains (#38315)

* fix: add passthru for some subdomains

* fix: export whitelist correctly
This commit is contained in:
mrugesh
2020-03-03 20:32:04 +05:30
committed by GitHub
parent 0b1ba11959
commit ac922ac04e
2 changed files with 18 additions and 1 deletions

View File

@ -1,8 +1,17 @@
import { homeLocation } from '../../../config/env';
import { whitelistOrigins } from '../../../config/cors-settings';
export default function constantHeaders() {
return function(req, res, next) {
res.header('Access-Control-Allow-Origin', homeLocation);
if (
req.headers &&
req.headers.origin &&
whitelistOrigins.includes(req.headers.origin)
) {
res.header('Access-Control-Allow-Origin', req.headers.origin);
} else {
res.header('Access-Control-Allow-Origin', homeLocation);
}
res.header('Access-Control-Allow-Credentials', true);
res.header(
'Access-Control-Allow-Headers',