question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fail prerendering if a page is shadowed by an endpoint

See original GitHub issue

Describe 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.

Screen Shot 2022-01-19 at 12 53 36

Let me know if you need more information 😎

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
Rich-Harriscommented, Jan 25, 2022

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 matching bob/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’.)

0reactions
tcc-sejohnsoncommented, May 4, 2022

I edited the PR description to include “fixes” before each issue number. You can see it linked the issues on the side of the PR so that they’ll be automatically closed if the PR is merged

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found