Hi everyone ! have a question concerning the integration of Keycloak.
Right now I created my realm, with users etc…
I’m developing an app on local using Vite for my front end (port 5173) and a local server to request datas from API (port 3000)
I have some CORS issues when I try to protect my API routes, and can’t figure why.
I’ve set up on my app.js all the informations needed, set the middleware and cors and then, on my routes, added keycloak.protect().
I’ve added localhost:3000 and localhost:5173 in my keycloak server (already hosted on the net)
Hi @matthieug the CORS error you’re seeing is because the browser is making a request to a different origin: to http://localhost:3000 from http://localhost:5173
You can fix this by using the Vite dev server proxy. Here’s an example. Tweak it to your needs:
Guys, your issue is not related to Keycloak, it’s a general issue when using cross-origin requests.
Please use a proper forum, so that we can keep our focus on Keycloak-only related topics!
Thanks for your understanding.
Sounds like zach-betz-hin found the problem. Indeed, the person I worked with put localhost:3000 directly in his code, and that was the issue…
Here is what it looked like @zach-betz-hln