# Keycloak throws CORS error after successful login

**URL:** <https://forum.keycloak.org/t/keycloak-throws-cors-error-after-successful-login/25598>\
**Category:** Configuring the server\
**Tags:** authentication\
**Created:** [April 16, 2024, 5:10pm UTC](https://forum.keycloak.org/t/keycloak-throws-cors-error-after-successful-login/25598 "2024-04-16T17:10:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelnicol2022](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/michaelnicol2022/32/10237_2.png) [@michaelnicol2022](https://forum.keycloak.org/u/michaelnicol2022)\
**Post date:** [April 16, 2024, 5:10pm UTC](https://forum.keycloak.org/t/keycloak-throws-cors-error-after-successful-login/25598/1 "2024-04-16T17:10:33Z")

</div>

Hello,

I am setting up Keycloak for the first time and am following this video to use Vite + React to create a login page: [https://youtu.be/5z6gy4WGnUs?feature=shared](https://youtu.be/5z6gy4WGnUs?feature=shared).

However, whenever I log in, it just causes a CORS error, and I have no idea why. Note, for the post below, I had to remove the HTTP part of the URL’s because new users can only have two links per post.

When I sign in at localhost:5173, everything is normal, and a login screen is prompted. But then, once I hit sign in, I get this token error.

> Access to XMLHttpRequest at ‘localhost:8080/realms/edgetak/protocol/openid-connect/token’ from origin ‘localhost:5173’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

> POST localhost:8080/realms/edgetak/protocol/openid-connect/token net::ERR\_FAILED 200 (OK)

Also note that Keycloak is failing to log out users according to the logs when I manually end sessions.

```auto
2024-04-16 12:59:29,284 WARN [org.keycloak.services.managers.AuthenticationManager] (executor-thread-49) Some clients have not been logged out for user michaelnicol in edgetak realm: edgetak

```

The response is also 200 according to the networking for request

> localhost:8080/realms/edgetak/protocol/openid-connect/token

Any ideas?
