I have a node.js express application with the following /token endpoint that can redirect to auth0 authorize endpoint
router.post('/token', limiter, oauth2Validations.validateCreateToken, (req, res) => {
const authInfo = _.clone(req.body)
const ip = req.ip
authInfo.ip = ip.split(',')[0]
if (!req.oidc.isAuthenticated()) {
return res.oidc.login({
authorizationParams: {
connection: 'Username-Password-Authentication',
},
})
}
usersApp
.oauth2PasswordAuth(authInfo)
.then((payload) => {
res.status(200).json(payload)
})
.catch((err) => {
processError(res, err)
})
})
When i call this endpoint and redirects to auth0, i always receive a CORS error:
I am running the api in localhost:3000 and frontend in localhost:3001, and already set both in Allowed Origins (CORS)
If i just get the /authorize url and copy and paste into a tab in the browser, it works
Somebody can belp?