Keycloak redirect_uri issue

I have a svelte app using keycloakjs, I have an issue with the redirect_uri
when i’m at a route like http://localhost/#/test for example, and I sign in from there, i’m redirected to the keycloak sign in page, with the url being something like

The issue i’m having is after signing in, keycloak redirects me back to the redirect_uri but it is including all the queryparams after it, so basically the redirect_uri is being set to http ://localhost:5001/#/test&state=63614ff5-fb16-4724-ba12-885227baad8f&session_state=17d5fca4-ead0-4cf0-96c5-bad19f15c883&code=912efd24-405b-452f-8b61-692c8057104f.17d5fca4-ead0-4cf0-96c5-bad19f15c883.b7522c9e-4728-4145-b768-0f5262a8e887
Instead of just http%3A%2F%2Flocalhost%3A5001%2F%23%2Ftest

This causes a problem with my router because that is an invalid url due to test&state

If this is intentional, then shouldn’t it be ?state= instead of &state=

I would say you asked for response in the fragment (see response_mode=fragment in the auth request). Your app should process those parameters from the fragment and clean the URL- you will end up with http://localhost/#/test URL and in the logged in app state.

Hmmm. I think it may also be a router issue, i’m using svelte-spa-router, what do you think? I’m not sure how to clean the URL, I tried before, but when I redirect I’m again in a logged out state. what type of redirect do i use? I was using window.location.replace

So my problem was my web server wasn’t configured for single page app
need to add --single to sirv

sirv --single

and if using nginx for production need to have index.html

location / {
root /usr/share/nginx/html
try_files $uri /index.html