I have CORS globally configured like this, to handle credentials:
app.use(cors({ origin: 'https://example.com', credentials: true }))
But on certain routes, I need to allow options requests, so following the documentation, I'm doing something like this:
router.options('/someroute', cors())
router.get('/someroute', cors(), someOtherMiddleware, async (req, res) => {
// do stuff
}
My global CORS policy seems to override the route policy, but only on the options method, I think. I'm trying to come up with a way to make both of these CORS policies play nicely. I have also tried the following, but this doesn't work either. Whichever one I put first seems to override the other one.
app.options('*', cors())
app.use(cors({ origin: 'https://example.com', credentials: true }))