-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
SvelteKit ignores page directives in +page.server.js
#5926
Comments
There's a couple of things going on here. While prerendering, SvelteKit will bail on any page that is not prerenderable, which includes If you change it back to what you were doing before... // src/routes/foo/+server.js
import { redirect } from '@sveltejs/kit';
/** @type {import('./$types').RequestHandler} */
export async function GET() {
return new Response(undefined, {
status: 302,
headers: {
location: '/foo/bar'
}
});
} ...then it will work, because it doesn't have a concept of 'prerenderable endpoints'. That's something we plan to change: #4093. |
@Rich-Harris Thanks for the help. I changed it back redirect in a standalone endpoint instead of the page endpoint and now it works. |
re-opening until we fix the 'SvelteKit ignores page directives in |
+page.server.js
Works great! Thanks!! |
Describe the bug
I have an app with pre-rendered pages. I'm NOT explicitly listing the pre-rendered pages in the svelte config, I'm letting the crawler discover them automatically. After migrating to
1.0.0-next.408
with the new routing, the pre-render crawler seems to be skipping pages if both of the following are true:It was working before the routing overhaul. See the stackblitz link below for a repro. The
/foo
route redirects to/foo/bar
which is handled by/foo/[slug]/+page.svelte
. The/foo2
route redirects to/foo2/bar2
which DOES NOT have a param, it just resolves to/foo2/bar2/+page.svelte
. Both page options areprerender = true
, and both are linked from the home. The first is NOT prerendering but the second is. In the repro, runnpm run build
to see that 1 is getting prerendered which the other is not.Before routing overhaul
This was working before the routing overhaul. Previously, I was doing my redirect within a standalone endpoint with something like
I also notice that the logs when I used to
npm run build
used to acknowledge my redirect:But now this no longer seems to be happening.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-btjtae?file=src%2Froutes%2Ffoo2%2Fbar2%2F%2Bpage.js&terminal=dev
Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: