You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Default behaviour of trailingSlash violated #11317
SvelteKit will remove trailing slashes from URLs by default according to the docs. This functionality is not fully provided anymore since #10763 got merged.
Using the default value for paths.base the trailing slash will be added to any sub route like /home/foo/. However, this trailing slash will be removed after reloading the page. Moreover, in case of the default value for paths.base there is no trailing slash at root.
I would expect that the default behaviour of trailingSlash page option is still valid for default paths.base even after merging #10763.
Reproduction
A minimal repro example of the issue can be found in this repo.
Ran into this in production! Was wondering why I was suddenly getting reports of 404s.
Digging into this, I noticed several more things:
If the page you initially visit is root ("/"), all pages are treated as trailingSlash = "always" until you refresh the page
If the first page you visit is a subdirectory ("/"), trailingSlash is properly respected until you refresh the page
Using the browser back button at any point seems to cause trailingSlash become properly respected
Explicitly defining trailingSlash = "never" does not change this behavior
This issue exists in both SvelteKit 1.30.1 and 2.0.0
Downgrading to 1.30.0 or earlier is my current solution
Reacted by Ayush Sehrawat , Tee Ming, Brian Morearty, Mawttehs, Simon Sarris, laszlo, Jonathan Holford, Christian Reinholdt, Thor Galle, M Stefan Walker and 1 more
For people still bumping on this, the latest 1.x version at the time of writing (1.30.4) still has the code that causes the trailing slash to always be added on navigations from the root page.
This was fixed in #11388 - but it seems that fix is only available in 2.x.
So your options on ^1.30.1 are either downgrading to 1.30.0, as mentioned above here, or upgrading to 2.x.
Reacted by Steve Cosman, M Stefan Walker, M Imam Pratama and Lythaeon
For people still bumping on this, the latest 1.x version at the time of writing (1.30.4) still has the code that causes the trailing slash to always be added on navigations from the root page.
This was fixed in #11388 - but it seems that fix is only available in 2.x.
So your options on ^1.30.1 are either downgrading to 1.30.0, as mentioned above here, or upgrading to 2.x.
Still relevant. Is there a new ticket tracking this issue? I'm using adapter-static so this bug is development-only in my case. Ideally, dev-mode routing mimics prod.
Activity
dangelomedinag commentedon Dec 15, 2023
same $page.url.pathname

mass8326 commentedon Dec 15, 2023
Ran into this in production! Was wondering why I was suddenly getting reports of 404s.
Digging into this, I noticed several more things:
trailingSlash = "always"until you refresh the pagetrailingSlash = "never"does not change this behaviorDowngrading to 1.30.0 or earlier is my current solution
deps: downgrade to fix sveltejs/kit#11317
feat: frontend fixes and improvements (#29)
fix trailing slash issue
downgrade sveltekit to fix sveltejs/kit#11317 (see tradingstrategy-ai…
Fix trailing slashes in routes (#139)
th0rgall commentedon May 13, 2024
For people still bumping on this, the latest 1.x version at the time of writing (1.30.4) still has the code that causes the trailing slash to always be added on navigations from the root page.
This was fixed in #11388 - but it seems that fix is only available in 2.x.
So your options on ^1.30.1 are either downgrading to 1.30.0, as mentioned above here, or upgrading to 2.x.
fix: downgrade @sveltejs/kit to 1.30.0 to prevent bug with always-add…
JTCorrin commentedon May 19, 2024
I'm on kit v2.0.0 and have this bug. This:
on:click={() => goto('/enterprise')}gives this in the address bar of the browser:
http://localhost:5173/enterprise/
bever1337 commentedon Jul 17, 2025
Still relevant. Is there a new ticket tracking this issue? I'm using adapter-static so this bug is development-only in my case. Ideally, dev-mode routing mimics prod.