Every line of 'cors npm' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
77 function setCors({whitelist = [], logger}) { 78 return cors({ 79 origin(origin, callback) { 80 if (whitelist.indexOf(origin) !== -1 || !origin) { 81 callback(null, true); 82 } else { 83 logger.warn({origin, whitelist}, 'Rejected by CORS'); 84 callback(new Error('Not allowed by CORS')); 85 } 86 }, 87 credentials: true, 88 }); 89 }
Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code
60 function setupCORS (api, path) { 61 api.paths[path].options = api.paths[path].options || cors 62 }