Last active
March 25, 2019 16:32
-
-
Save inodaf/4f2581fac0e1c8484bbec86e66cffbf7 to your computer and use it in GitHub Desktop.
Falando em Falhas: 2K to rule the life.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Setting dynamic CORS for non-options Request | |
app.use(cors((req, cb) => { | |
const companyDNS = '.mycompany.xyz' | |
const isTrusted = req.header('Origin').indexOf(companyDNS) >= 1 | |
// Some more business logics... | |
return cb(null, { | |
credentials: true, | |
origin: isTrusted | |
}) | |
})) | |
// Setting Default CORS for Option Requests | |
app.options('*', cors({ credentials: true, origin: true })) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment