Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const injectCspHeader = (req, res, next) => {
const { isAmp } = getRouteProps(routes, req.url);
const originHeader = req.headers['bbc-origin'];
const { origin, isUK } = getOriginContext(originHeader);
const isLive = origin === 'https://bbc.co.uk' || origin === 'https://bbc.com';
const context = generateCspContext(isAmp, isUK, isLive);
const middleware = csp(constructCspHeader(context));
middleware(req, res, next);
};