Closed feavel1 closed 4 days ago
Fun fact, local development has no issue. Been banging my head for a day now. Maybe someone has had same problem ?
My code repository is here https://github.com/feavel1/feavel
Should add a scope:
scope: inlang/paraglide-js
The odd thing is that it seems to work when you start out on https://feavel.com and then switch the language to zh
. To me this suggests that this might be an issue with @svelte/adapter-vercel
. It may not be playing nice with the reroute
hook added in SvelteKit 2.3
I checked out you repo locally & built it. If you inspect .vercel/output/config.json
you can see the path definitions that will be used by vercel. The reroute
hook isn't being considered. This is a bug in the Vercel Adapter, I'll open an issue
The odd thing is that it seems to work when you start out on https://feavel.com and then switch the language to
zh
. To me this suggests that this might be an issue with@svelte/adapter-vercel
. It may not be playing nice with thereroute
hook added in SvelteKit 2.3
I am using svelte-adapter-auto svelte.config.js,maybe something with the build steps that doesn't tell Vercel that there is /{lang} that can be used...
The hook is also setup the way docs tell to. Strange
@sveltejs/adapter-auto
will magically turn into @sveltejs/adapter-vercel
when the build is being run inside vercel's pipeline.
I can confirm that you did set up everything correctly. This is a bug in @sveltejs/adapter-vercel
& not your fault.
I'll be opening an Issue in the sveltejs/kit repo about this.
In the mean time you could:
.vercel/output/config.json
after npm run build
to add a copy of every route with /zh
in front. You can see the vercel build by switching to @sveltejs/adapter-vercel
in svelte.config.js
(it's already installed in your repo)It seems to be a bit more nuanced actually. The reroute
hook works on vercel, until your app starts reaching a certain bundle size. At some point the Adapter will start creating multiple Vercel Serverless functions instead of just one for the entire app. At that point it breaks
Serverless
Thank you for testing the code and finding out what's going on. I am wondering if it is possible to rewrite the "reroute" hook so it can be used? Or maybe find a function that can be used to pre-render the page that needs to be loaded?
Wired with Vercel but here is the docs for svelte function universal-hooks-reroute
Side-stepping the reroute
hooks could maybe be possible if you aren't using any translated pathnames.
Try removing the reroute
hook & instead adding an optional [[lang]]
parameter at the base of your routes. Maybe that could work.
instead
Man of culture, this day was very long. Maybe the next day will shine brighter. Wish me best luck of figuring out how to solve this mysterious technology.
I have to say that taking the time to run the code and figuring out what the issue is, also suggesting what the solution is just ... very nice of you. Hope I will solve the problem.
But even if I don't , it is great to see you. Wish you all the best 🔆☀️🌞
Being worked on in https://github.com/sveltejs/kit/pull/12296
instead
Man of culture, this day was very long. Maybe the next day will shine brighter. Wish me best luck of figuring out how to solve this mysterious technology.
I have to say that taking the time to run the code and figuring out what the issue is, also suggesting what the solution is just ... very nice of you. Hope I will solve the problem.
But even if I don't , it is great to see you. Wish you all the best 🔆☀️🌞
Have you found the solution? I have exact same problem. Once I refresh it will show 404 and it's annoying.
EDIT: I had export const prerender = true;. I removed it and now everything works.
Closing as stale.
Problem
After I upload the project to vercel, the issue occurs.
I can't visit pages like https://feavel.com/zh or https://feavel.com/zh/services.
But everything works locally. Also the local build has no issues. Maybe something with vercel cache? I don't know.
Expected behavior
I can use the lang switcher to change the language and everything works as expected. Even in local development no issues occur, no matter if it's dev or build preview. But after I upload the build to vercel, the issue occurs. I can't visit pages like https://feavel.com/zh or https://feavel.com/zh/services .
Reproduction
Go to pages like https://feavel.com/zh or https://feavel.com/zh/services
Try to switch language, and everything works again. But reloading doesn't.
Other information
Safari
macOS