-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error pages in SPA mode adapter-static
#2454
Comments
@gyurielf could you create a repository that reproduces this? We've got a bunch of open issues and we wouldn't have time to do that for all 200+ of them, so it would really help in getting someone to look at this. Thanks! |
Thanks for the reply! Sure! Give me 1-2 day please, and I will share the repo link here. |
https://github.com/gyurielf/sveltekit-spa-demo So now you can test it. for e.g. hit: The errors are always will be rendered by the root's folder __error.svelte. |
Not absolutely sure but this looks like it's coming from this line :
|
If specified unknown path, should we render like According to document, Actually after implementing this dynamic fallback for 404, I want to know actual specification before create PR. Just should we implement dynamic fallback? |
Let's assume we have a logged in user on a dashboard and this user has an old bookmark in his browser or an old link in the browser history.
So I think it's a normal to handle errors just how we would like to handle and where we would like to handle. |
Thank you for your comment!
I checked Nuxt's document to find out how other FWs are doing.
So your opinion and my current direction looks okay after refactoring and writing tests. |
@baseballyama Awesome! Thank you. Can I help you somehow ? |
It's still actual. |
To clarify, this is nothing to do with whether the app is an SPA or not or whether the fallback is correctly configured. Everything is working as intended! Non-root error pages are rendered when an error occurs while rendering a specific page. A 404 indicates that there was no specific page to render. If you want to render different error pages for paths that begin with something specific like <script context="module">
/** @type {import('@sveltejs/kit').Load} */
export function load({ params }) {
return {
status: 404,
error: new Error(`Not found ${params.path}`)
};
}
</script> |
Describe the bug
Hello Svelte community!
I ran into a problem with the error pages.
First of all, I use sveltkit with adapter-static and with
fallback: '404.html'
(So in SPA mode) and I prerender non-dynamic pages withexport const prerender = true
.This app served from a cdn, which is simply serve static files.
When I get a 404 error, because the path (and the prerendere file ofc.) isn't exist, if I know correctly, it will be falling back to the fallback 404.html which I set in the
adapter-static
and the it will handle the things hereinafter.But the 404 error is always rendered with the root _error.svelte and __layout.svelte.
The SvelteKit ignore the actual path __error.svelte page.
https://kit.svelte.dev/docs#layouts-error-pages
Here is my tree:
So when I hit myurl.com/app/3216836281.
The root error will be rendered for me which is in the routes, not the correct one, which is in the /app.
I misunderstand something?
Reproduction
Set up a project and use it in SPA mode.
Set prerender=true at least one page.
Set a file structure like in the description.
Hit an url, which isn't exist.
Logs
No response
System Info
System: OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa) CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 3.20 GB / 15.49 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 16.9.1 - /usr/bin/node npm: 7.21.1 - /usr/bin/npm Browsers: Chrome: 93.0.4577.82 Firefox: 92.0 npmPackages: @sveltejs/adapter-static: 1.0.0-next.19 @sveltejs/kit: next => 1.0.0-next.169 svelte: 3.42.6
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: