Files
freeCodeCamp/api-server/server/middlewares/constant-headers.js
Mrugesh Mohapatra c23c4ef8e4 fix: negative sentiment → neutral language (#39522)
The existing terminology carries negative sentiment that can be
interpreted in a racial or sense. Updating the name to have no
potential for such a connection.

Co-authored-by: Justin Rogers <justrog@gmail.com>
2020-09-07 11:04:44 +05:30

23 lines
657 B
JavaScript

import { homeLocation } from '../../../config/env';
import { allowedOrigins } from '../../../config/cors-settings';
export default function constantHeaders() {
return function(req, res, next) {
if (
req.headers &&
req.headers.origin &&
allowedOrigins.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',
'Origin, X-Requested-With, Content-Type, Accept'
);
next();
};
}