Keycloak throws CORS error after successful login

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.

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.

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?