opral / inlang-paraglide-js

Tree-shakable i18n library build on the inlang ecosystem.
https://inlang.com/m/gerre34r/library-inlang-paraglideJs
42 stars 0 forks source link

Routing does not work in SvelteKit with trailingSlash = 'always' #65

Closed pago93 closed 5 months ago

pago93 commented 6 months ago

The reroute hook does not work if export const trailingSlash = 'always'; is set in +layout.ts.

It behaves like no route is present at all:

SvelteKitError: Not found: /de/
    at resolve (G:\test\my-app\node_modules\@sveltejs\kit\src\runtime\server\respond.js:522:13)
    at resolve (G:\test\my-app\node_modules\@sveltejs\kit\src\runtime\server\respond.js:322:5)
    at Object.eval [as handle] (G:\test\my-app\node_modules\@inlang\paraglide-js-adapter-sveltekit\dist\runtime\hooks\handle.js:23:16)
    at Module.respond (G:\test\my-app\node_modules\@sveltejs\kit\src\runtime\server\respond.js:319:40)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  status: 404,
  text: 'Not Found'
}

Would be great to get this working. In hosting scenarios with @sveltejs/adapter-static this setting is sometimes inevitable.

LorisSigrist commented 5 months ago

I found some cases where the adapter was accidentally removing trailing slashes.

In the linked PR I fixed those & added a bunch of tests to ensure that trailingSlashes are preserved if present on all link-transformations. That should fix any issues. The example project is now using trailingSlash="always" and everything seems to be working perfectly.

pago93 commented 5 months ago

Can confirm it is working now with v 0.5.22.

Thank you very much for the fast response!

LorisSigrist commented 5 months ago

No problem! If it's working in 0.5.22 then I found some additional issues. Those will be fixed in 0.6.0.

I just realized that the PR is only linked in Linear and not on Github. I was referring to this: https://github.com/opral/monorepo/pull/2542

pago93 commented 5 months ago

It seems like there's still a little bug. Directly opening the root with another language gets me a 404. Other addresses work fine.

Just the initial loading doesn't work. Switching languages when the app is loaded does seem to be working fine.

LorisSigrist commented 5 months ago

Good catch, on it

LorisSigrist commented 5 months ago

New PR, should fix the issue https://github.com/opral/monorepo/pull/2543

LorisSigrist commented 5 months ago

v6.0.1 fixes the issue (hopefully for real this time)