CORS error with /v1/authorize

Why am I getting a CORS error calling the /v1/authorize end point when I have added localhost to Trusted Origins? I only seem to be able to get this to work when I put the URL together with query params and call it directly in the browser.

const result = await axios({
       method: "Post",
       headers: {
           'Content-Type': 'text/plain',
           'Access-Control-Allow-Origin': '*'
       },
       url: 'https://dev-123456.okta.com/oauth2/v1/authorize',
       data: {
          client_id: 'client_id_added_here',
          response_type: 'id_token',
          scope: 'openid%20groups',
          redirect_uri: 'http://localhost:3000/auth',
          state: 'myState',
          nonce: 'myNonceValue'
       }
})

Security > API > Trusted Origins:

Hi there. Calls to the /authorize need to be redirects, not AJAX calls. See the note in our docs:

Note: When making requests to the /authorize endpoint, the browser (user agent) should be redirected to the endpoint. You can’t use AJAX with this endpoint.

1 Like

Thank you for the quick reply. I did read that; I just didn’t want to believe it. I appreciate you confirming it for me.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.