CORS error when trying to access the 'oauth/token' endpoint

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('', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
      }, tokenParams)
      .then((res) => res.json())
      .then((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.

1 Like