-
-
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
Prerendered endpoint cannot be fetched by provided fetch in server load #8341
Comments
I ran into the exact same problem. Im doing the fetch from a load function in Thanks for the tip using native fetch and url.origin, this seem to work when I do Edit: native fetch and inserting url.origin in the fetch URL worked fine on Vercel as well. Will run with that and keep an eye on this issue. |
This happens because the endpoint ( |
Describe the bug
A
+page.svelte
with+page.server.js
using providedfetch
inload
cannot fetch prerendered endpoint (+server.js
) after buildClick to the page will give
500 Internal Error
Error: Not found: /api/something
,However, it will be okay only if you refresh the page
I tried different methods, found that
Methods that always work
Methods that does not work
According to https://kit.svelte.dev/docs/load#making-fetch-requests, I suspect that the provided
fetch
somehow stripped out the origin. It turned the fetch into an internal request to a prerendered route/api/something
, which did not exist, and should belocalhost:4173/api/something
insteadNote: It also happened using
@sveltejs/adapter-vercel
Related issue (I suspect)
#8039
#8331
Reproduction
https://github.com/benlau6/sveltekit-fetch-prerendered-endpoint-issue
Logs
System Info
Severity
serious, but I can work around it
Additional Information
No response
The text was updated successfully, but these errors were encountered: