Skip to content
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

fetch passed to load function in +page.server.js implements CORS #7441

Closed
Theo-Steiner opened this issue Oct 30, 2022 · 1 comment · Fixed by #7454
Closed

fetch passed to load function in +page.server.js implements CORS #7441

Theo-Steiner opened this issue Oct 30, 2022 · 1 comment · Fixed by #7454
Labels
bug Something isn't working
Milestone

Comments

@Theo-Steiner
Copy link
Contributor

Theo-Steiner commented Oct 30, 2022

Describe the bug

Even though it will only ever run on the server, the fetch implementation that is passed to load in +page.server.js is checking for CORS, behaving as if it were called in a browser.

I assume this might be an oversight from when +page.server routes were first introduced, since obviously you'd very much want this behavior in non-server page.js load function, but it doesn't really make any sense in the new environment.

I hope I didn't overlook an issue where this was discussed already and kept for technical reasons, but even then we'd probably want this documented.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-52u2qj?file=src%2Froutes%2F%2Blayout.svelte,src%2Froutes%2F%2Bpage.svelte,src%2Froutes%2F%2Bpage.server.js&terminal=dev

Logs

No response

System Info

stackblitz

Severity

annoyance

The global fetch correctly doesn't implement CORS, so one can simply use that. However it is a bit confusing getting a CORS error from a request you make on the server.

Additional Information

No response

@pheuter
Copy link

pheuter commented Oct 30, 2022

Some discussion here for additional context: https://discord.com/channels/457912077277855764/1035096174014771231/1035096174014771231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants