# Cross origin issue

**URL:** <https://devforum.okta.com/t/cross-origin-issue/11086>\
**Category:** Questions\
**Tags:** angularjs\
**Created:** [September 25, 2020, 2:30pm UTC](https://devforum.okta.com/t/cross-origin-issue/11086 "2020-09-25T14:30:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![prashantHt](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@prashantHt](https://devforum.okta.com/u/prashantHt)\
**Post date:** [September 25, 2020, 2:30pm UTC](https://devforum.okta.com/t/cross-origin-issue/11086/1 "2020-09-25T14:30:53Z")

</div>

Hello i am working with Angular 5 and okta, I am facing cross origine issue from my local  
I have configured my local baseurl “[http://localhost:4200/](http://localhost:4200/)” as allow origin  
but still get  
has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.  
please help me if any solution

---

<div class="post-metadata">

**Author:** ![phi1ipp](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@phi1ipp](https://devforum.okta.com/u/phi1ipp)\
**Post date:** [September 25, 2020, 8:43pm UTC](https://devforum.okta.com/t/cross-origin-issue/11086/2 "2020-09-25T20:43:33Z")

</div>

what is the request which fails?

---

<div class="post-metadata">

**Author:** ![prashantHt](https://avatars.discourse-cdn.com/v4/letter/p/eada6e/32.png) [@prashantHt](https://devforum.okta.com/u/prashantHt)\
**Post date:** [September 28, 2020, 9:12am UTC](https://devforum.okta.com/t/cross-origin-issue/11086/3 "2020-09-28T09:12:16Z")

</div>

All Okta api request for example .

“https://${yourOktaDomain}/api/v1/users?limit=200”

---

<div class="post-metadata">

**Author:** ![phi1ipp](https://avatars.discourse-cdn.com/v4/letter/p/85f322/32.png) [@phi1ipp](https://devforum.okta.com/u/phi1ipp)\
**Post date:** [September 28, 2020, 11:03am UTC](https://devforum.okta.com/t/cross-origin-issue/11086/4 "2020-09-28T11:03:10Z")

</div>

this one is not CORS enabled. You can only call those APIs which are tagged as “CORS” in the documentation

---

<div class="post-metadata">

**Author:** ![jefryarch](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@jefryarch](https://devforum.okta.com/u/jefryarch)\
**Post date:** [May 10, 2022, 7:14am UTC](https://devforum.okta.com/t/cross-origin-issue/11086/5 "2022-05-10T07:14:42Z")

</div>

> [@prashantHt](#):
>
> No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

The Same Origin Policy (SOP) is the policy browsers implement to prevent vulnerabilities via Cross Site Scripting (XSS). In other words, the browser would not allow any site to make a request to any other site. It would prevent different origins from interacting with each other through such requests, like AJAX. This policy exists because it is too easy to inject a link to a javascript file that is on a different domain. This is a security risk - you really only want code that comes from the site you are on to execute and not just any code that is out there.

The Cross Origin Resource Sharing (CORS) is one of the few techniques for relaxing the SOP. Because SOP is “on” by default, setting CORS at the server-side will allow a request to be sent to the server via an XMLHttpRequest even if the request was sent from a different domain. This becomes useful if your server was intended to serve requests from other domains (e.g. if you are providing an API).

JSON with Padding is just a way to circumvent same-origin policy, when CORS is not an option. This is risky and a bad practice. Avoid using this.

If you want to bypass that restriction when fetching the contents with fetch API or XMLHttpRequest in [javascript](http://net-informations.com/js/default.htm), you can use a proxy server so that it sets the header Access-Control-Allow-Origin to \*.

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`

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [February 12, 2024, 7:31pm UTC](https://devforum.okta.com/t/cross-origin-issue/11086/6 "2024-02-12T19:31:27Z")

</div>

Closed on February 12, 2024, 7:31pm UTC

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