<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z000074vC6iCAEOkta Classic EngineAuthenticationAnswered2024-03-25T16:54:13.000Z2021-07-23T18:05:18.000Z2021-09-20T07:03:38.000Z

SuhailJ.74625 (Customer) asked a question.

No 'Access-Control-Allow-Origin' header is present on the requested resource. while calling okta api through angular application

I am trying to call okta api to get all users from my angular application

https://{{okta-dev-domain}}/api/v1/users

but I am getting "No 'Access-Control-Allow-Origin' header is present on the requested resource" error.

I have also added my angular app origin at  API > Trusted Origins

Also tried by adding SWSS {{api token}} in request headers but getting the same errorr


  • sv4y9 (sv4y9)

    This is happening because of the CORS (Cross Origin Resource Sharing) . For every HTTP request to a domain, the browser attaches any HTTP cookies associated with that domain. This is especially useful for authentication, and setting sessions. You are doing an XMLHttpRequest to a different domain than your page is on. So the browser is blocking it as it usually allows a request in the same origin for security reasons. You need to do something different when you want to do a cross-domain request.

     

    JSONP ( JSON with Padding ) is a method commonly used to bypass the cross-domain policies in web browsers. You’re on domain example.com , and you want to make a request to domain example.nett . To do so, you need to cross domain boundaries. JSONP is really a simple trick to overcome the XMLHttpRequest same domain policy. So, instead of using XMLHttpRequest we have to use < script > HTML tags, the ones you usually use to load JavaScript files , in order for JavaScript to get data from another domain.

     

    Localhost

     

    If you need to enable CORS on the server in case of localhost, you need to have the following on request header.

     

    Access-Control-Allow-Origin: http://localhost:9999

     

     

    Expand Post
This question is closed.
Loading
No 'Access-Control-Allow-Origin' header is present on the requested resource. while calling okta api through angular application