# Domain has been blocked by CORS policy: No 'Access-Control-Allow-Origin'

**URL:** <https://community.auth0.com/t/domain-has-been-blocked-by-cors-policy-no-access-control-allow-origin/61515>\
**Category:** Get Help\
**Tags:** cors\
**Created:** [April 21, 2021, 8:35pm UTC](https://community.auth0.com/t/domain-has-been-blocked-by-cors-policy-no-access-control-allow-origin/61515 "2021-04-21T20:35:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JulesR2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/julesr2/32/25369_2.png) [@JulesR2](https://community.auth0.com/u/JulesR2)\
**Post date:** [April 21, 2021, 8:35pm UTC](https://community.auth0.com/t/domain-has-been-blocked-by-cors-policy-no-access-control-allow-origin/61515/1 "2021-04-21T20:35:54Z")

</div>

Hi !

I’ve been trying to set up a basic authentication integration to my angular SPA with PHP backend. I’ve mostly been following [this](https://code.mendhak.com/angular-dynamic-configuration-with-auth0/) as well as Auth0 documentation.

At this point, the backend is basically the code provided by the official doc :

```
    public function authenticate($get) {
         if (! empty($get['error']) || ! empty($get['error_description'])) {
             printf( '<h1>Error</h1><p>%s</p>', htmlspecialchars( $get['error_description'] ) );
         die();
    }

    $auth0 = new Auth0([
        'domain' => 'auth0domain',
        'client_id' => 'clientID',
        'client_secret' => 'XXX',
        'redirect_uri' => 'https://st-frontend.auth.test:4200/',
        'scope' => 'openid email profile',
    ]);
    
    try {
        $userinfo = $auth0->getUser();
    } catch (Exception $e) {
        die( $e->getMessage() );
    }
    
    if (empty($userinfo)) {
        $auth0->login();
    }
    
    echo 'ok';
}

```

On the frontend side, I’m calling this endpoint and setting up the authClientConfig

```
this.authClientConfig.set({
    clientId: AppConfigService.settings.clientId,
    domain: AppConfigService.settings.domain
 });

```

Of course, I’ve read many posts on this subject already and tried to apply all solutions. Both frontend and backend on HTTPS with a valid certificate, no localhost, URLs added to the Application URIs settings.  
Still, I keep getting this error on CORS policy (both Chrome and Firefox) :

Access to XMLHttpRequest at ‘auth0domain/authorize?scope=openid%20email%20profile&response\_mode=query&response\_type=code&redirect\_uri=https%3A%2F%2Fst-frontend.auth.test%3A4200%2F&state=da30ce31ccc45bd7e1e18a9ec861c1c1&nonce=c1dfae0ab77213c18b4dd064620d35b7&client\_id=clientID’ (redirected from ‘[https://st-backend.dev/api/v1/auth](https://st-backend.dev/api/v1/auth)’) from origin ‘[https://st-frontend.auth.test:4200](https://st-frontend.auth.test:4200)’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Any ideas ?

---

<div class="post-metadata">

**Author:** ![luuuis](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/luuuis/32/27105_2.png) [@luuuis](https://community.auth0.com/u/luuuis)\
**Post date:** [April 22, 2021, 2:37pm UTC](https://community.auth0.com/t/domain-has-been-blocked-by-cors-policy-no-access-control-allow-origin/61515/2 "2021-04-22T14:37:02Z")

</div>

> [@JulesR2](#):
>
> Access to XMLHttpRequest at ‘auth0domain/authorize?scope=openid%20email%20profile&response\_mode=query&response\_type=code&redirect\_uri=https%3A%2F%2Fst-frontend.auth.test%3A4200%2F&state=da30ce31ccc45bd7e1e18a9ec861c1c1&nonce=c1dfae0ab77213c18b4dd064620d35b7&client\_id=clientID’ (redirected from ‘[https://st-backend.dev/api/v1/auth’](https://st-backend.dev/api/v1/auth%E2%80%99)) from origin ‘[https://st-frontend.auth.test:4200](https://st-frontend.auth.test:4200)’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Your snippet indicates that you are using XMLHttpRequest. Calls to `/authorize` can never be made with XMLHttpRequest. They should only be made via a redirect or other top-level browser navigation and this is why CORS is not supported at that API.

Please check this similar question where I explained this in a bit more detail [Received CORS issue trying to reproduce quickstart demo in Rails - #4 by luuuis](https://community.auth0.com/t/received-cors-issue-trying-to-reproduce-quickstart-demo-in-rails/60143/4)

Hope this helps.

---

<div class="post-metadata">

**Author:** ![JulesR2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/julesr2/32/25369_2.png) [@JulesR2](https://community.auth0.com/u/JulesR2)\
**Post date:** [April 22, 2021, 8:33pm UTC](https://community.auth0.com/t/domain-has-been-blocked-by-cors-policy-no-access-control-allow-origin/61515/3 "2021-04-22T20:33:20Z")

</div>

That was the issue indeed. Thanks a lot.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 23, 2021, 6:25am UTC](https://community.auth0.com/t/domain-has-been-blocked-by-cors-policy-no-access-control-allow-origin/61515/4 "2021-04-23T06:25:40Z")

</div>

Perfect! Thanks for helping on this one @luuuis !

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [April 29, 2021, 12:20pm UTC](https://community.auth0.com/t/domain-has-been-blocked-by-cors-policy-no-access-control-allow-origin/61515/5 "2021-04-29T12:20:54Z")

</div>


