Fail prerendering if a page is shadowed by an endpoint
See original GitHub issueDescribe the bug
If you create a bob/index
with a POST and bob/index.svelte
--> posting will not work when deployed to Vercel.
Vercel throws error 405.
Reproduction
Deploy this repo to Vercel, and visit /bob
and hit the submit button - and then the error will appear.
As long as it exists 😅, you can also try it here: https://sveltekit-p9hxntt45-jeddah.vercel.app/bob
Logs
No response
System Info
Latest version `next` of kit and vercel adapter.
Severity
serious, but I can work around it
Additional Information
I can simply work around by not enabling prerender=true
on the sveltekit component.
Let me know if you need more information 😎
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Page/Shadow Endpoint in Sveltekit - YouTube
In this video, I will be showing how to use page endpoints or previously called as shadow endpoints in Sveltekit.00:00 Intro00:29 How to ......
Read more >Optional SSR/Prerendering in Sveltekit - YouTube
In this video I will be showing how to optionally not prerender (SSR) certain pages in Sveltekit app.Sometimes - for certain pages in ......
Read more >Protected shadow endpoints - svelte - Stack Overflow
I want my selected shadow endpoints to return the value if the access_token in the cookies is valid. So, I want to be...
Read more >Geoff Rich on Twitter: "Essentially, if you have a page and an ...
With shadow endpoints providing a page's props, you can now respond to a POST with validation errors that will then be used to...
Read more >Preview without rendering in After Effects - Adobe Support
When you press spacebar (the default keyboard shortcut), After Effects starts a preview with audio, and caches frames until the available RAM is ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is expected behaviour — prerendered pages always take priority over dynamic endpoints. The reason for that is that in most environments (Vercel included) there isn’t even an opportunity to run SvelteKit if a matching file exists on the filesystem. The 405 you’re seeing is coming from Vercel itself, which sees a request for
/bob
, sees that there’s a matchingbob/index.html
file already prerendered, then says ‘hang on a minute, you can’t POST to a prerendered file’.So you’ll always need to disable prerendering for these pages. We could probably do a better job of diagnosing this at build time — if a page is shadowed by an endpoint, prerendering should fail. (When we implement #3532, we can change that to ‘if a page is shadowed by an endpoint with non-GET handlers’.)
Thanks! I was wondering why some of my PRs would auto-close issues and others wouldn’t… I edited the few I have open as well.