I am trying to get an access_token whenever my user logs in. I currently try to fetch this token in javascript:
let tokenParams = {
grant_type: "authorization_code",
client_id: process.env.AUTH0_CLIENT_ID,
client_secret: process.env.AUTH0_CLIENT_SECRET,
code: router.query.code,
redirect_uri: process.env.AUTH0_BASE_URL
};
useEffect(() => {
fetch('https://neume.eu.auth0.com/oauth/token', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}, tokenParams)
.then((res) => res.json())
.then((data) => {
console.log(data);
})
}, [])
However, no matter what i try to do it returns a CORS error. I tried setting the allowed origins in the settings to http://localhost:3000 but no succes. I am lost and i can’t find any solution online either, so i hope anyone here can help me.