# React: CORS error when invoking auth.logout

**URL:** <https://devforum.okta.com/t/react-cors-error-when-invoking-auth-logout/1196>\
**Category:** Questions\
**Created:** [February 7, 2018, 5:57pm UTC](https://devforum.okta.com/t/react-cors-error-when-invoking-auth-logout/1196 "2018-02-07T17:57:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aarestad](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@aarestad](https://devforum.okta.com/u/aarestad)\
**Post date:** [February 7, 2018, 5:57pm UTC](https://devforum.okta.com/t/react-cors-error-when-invoking-auth-logout/1196/1 "2018-02-07T17:57:38Z")

</div>

When I invoke `auth.logout()` in my React app while logged in, I appear to be logged out correctly (refreshing the app shows that I need to re-authenticate) but instead of forwarding me to the Okta login page after logging out, I receive a CORS error visible on my console:

`Failed to load https://dev-654950.oktapreview.com/api/v1/sessions/me: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localtempus.com:3400' is therefore not allowed access.`

Is there some configuration that I missed in the application settings in the Okta console? Here’s what I think is the relevant config:

![11%20AM](https://global.discourse-cdn.com/oktadev/original/1X/624fd422c318e1a67191faf65b56cfe990eb0dc8.png)

Thanks!

---

<div class="post-metadata">

**Author:** ![tom](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/tom/32/24_2.png) [@tom](https://devforum.okta.com/u/tom)\
**Post date:** [February 7, 2018, 6:01pm UTC](https://devforum.okta.com/t/react-cors-error-when-invoking-auth-logout/1196/2 "2018-02-07T18:01:05Z")

</div>

> [@aarestad](#):
>
> [http://localtempus.com:3400](http://localtempus.com:3400)

There is another spot that you need to update, `API->Trusted Origin`, you will want to add `http://localtempus.com:3400` as a trusted CORS origin. The reason for this is where Okta is allowed to redirect to is different than where there is code that needs to make a call to our API.

Let me know if this fixes the issue for you!

---

<div class="post-metadata">

**Author:** ![aarestad](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@aarestad](https://devforum.okta.com/u/aarestad)\
**Post date:** [February 7, 2018, 6:08pm UTC](https://devforum.okta.com/t/react-cors-error-when-invoking-auth-logout/1196/3 "2018-02-07T18:08:54Z")

</div>

Yeah, that was it - thank you! Still learning the basics here. 🙂

---

<div class="post-metadata">

**Author:** ![MichaelAdewunmi](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/michaeladewunmi/32/623_2.png) [@MichaelAdewunmi](https://devforum.okta.com/u/MichaelAdewunmi)\
**Post date:** [August 3, 2018, 8:44am UTC](https://devforum.okta.com/t/react-cors-error-when-invoking-auth-logout/1196/4 "2018-08-03T08:44:31Z")

</div>

Hello @tom. How are you doing? I am stuck with this issue too. I keep getting the CORS error in my developer console in chrome. Although, in my case, I can successfully log in and authenticate users. However, I am trying to update users using a react app. I can also successfully GET user but when I try to use the POST or PUT for updating users, it gives me the CORS error.

_Failed to load [https://myoktaname.com/api/v1/users/{myuserid}](https://myoktaname.com/api/v1/users/%7Bmyuserid%7D) Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘[http://localhost:3000](http://localhost:3000)’ is therefore not allowed access. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled._

I have added localhost:3000 as trusted origin in the API section and my login redirects are set as [http://localhost:300/implicit/callback](http://localhost:300/implicit/callback) but I still get the same CORS error. Could there be anything I am missing? I’ll be glad to get some help at this stage. Thanks a lot.

---

<div class="post-metadata">

**Author:** ![MichaelAdewunmi](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/michaeladewunmi/32/623_2.png) [@MichaelAdewunmi](https://devforum.okta.com/u/MichaelAdewunmi)\
**Post date:** [August 3, 2018, 10:08am UTC](https://devforum.okta.com/t/react-cors-error-when-invoking-auth-logout/1196/5 "2018-08-03T10:08:24Z")

</div>

@tom haaaa thanks. You actually solved the problem in this reply. [CORS Issues while testing on device](https://devforum.okta.com/t/cors-issues-while-testing-on-device/857/7) 😀 . I’m glad I was able to solve the problem. I’ve been on it since yesterday.

So, In case anyone is having the same problem too, follow the link in this reply and check @tom’s response. It is likely to be the actual solution. Thanks a lot @tom.

---

<div class="post-metadata">

**Author:** ![ramv7983](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@ramv7983](https://devforum.okta.com/u/ramv7983)\
**Post date:** [August 30, 2018, 8:55pm UTC](https://devforum.okta.com/t/react-cors-error-when-invoking-auth-logout/1196/6 "2018-08-30T20:55:07Z")

</div>

@tom can you please help me with same kind of issue at here:

> [@CORS Problem Sign on widget](https://devforum.okta.com/t/cors-problem-sign-on-widget/2609/8):
>
> Maybe you want to port your code to a test server that is accessible by a domain name. I had to do the same and it worked after I added the domain name of the test server.

---

<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:** [April 26, 2022, 7:31pm UTC](https://devforum.okta.com/t/react-cors-error-when-invoking-auth-logout/1196/7 "2022-04-26T19:31:20Z")

</div>

Closed on April 26, 2022, 7:31pm UTC

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