Every line of 'npm install cors' 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.
158 function setupCors(swaggerApp, remotes) { 159 var corsOptions = remotes.options && remotes.options.cors || 160 { origin: true, credentials: true }; 161 162 // TODO(bajtos) Skip CORS when remotes.options.cors === false 163 swaggerApp.use(cors(corsOptions)); 164 }
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
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 }
60 function setupCORS (api, path) { 61 api.paths[path].options = api.paths[path].options || cors 62 }