fix: add pass thru for some subdomains (#38315)
* fix: add passthru for some subdomains * fix: export whitelist correctly
This commit is contained in:
@ -1,8 +1,17 @@
|
|||||||
import { homeLocation } from '../../../config/env';
|
import { homeLocation } from '../../../config/env';
|
||||||
|
import { whitelistOrigins } from '../../../config/cors-settings';
|
||||||
|
|
||||||
export default function constantHeaders() {
|
export default function constantHeaders() {
|
||||||
return function(req, res, next) {
|
return function(req, res, next) {
|
||||||
|
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-Origin', homeLocation);
|
||||||
|
}
|
||||||
res.header('Access-Control-Allow-Credentials', true);
|
res.header('Access-Control-Allow-Credentials', true);
|
||||||
res.header(
|
res.header(
|
||||||
'Access-Control-Allow-Headers',
|
'Access-Control-Allow-Headers',
|
||||||
|
8
config/cors-settings.js
Normal file
8
config/cors-settings.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
exports.whitelistOrigins = [
|
||||||
|
'https://www.freecodecamp.dev',
|
||||||
|
'https://www.freecodecamp.org',
|
||||||
|
'https://beta.freecodecamp.dev',
|
||||||
|
'https://beta.freecodecamp.org',
|
||||||
|
'https://chinese.freecodecamp.dev',
|
||||||
|
'https://chinese.freecodecamp.org'
|
||||||
|
];
|
Reference in New Issue
Block a user