Fetch in load function not sending cookie when in production
See original GitHub issueDescribe the bug
- No issue in setting a cookie. Cookie is set and present in browser.
- Cookie is being sent by the same code when it is running in localhost .
- Problem : In production, fetch in load function isn’t sending cookie, but browser fetch is able to send cookie.
Reproduction
I created a svelte-kit repo running on https://expense.satyam.life/ . When you run it it just shows you a button set cookie. When you click the button cookie is set using an endpoint and you are redirected to a page displaying cookie sent by load_fetch and browser_fetch.
The backend fastify repo](https://github.com/mishrasatyam/fastify_send_read_cookie) is running on https://expenseapi.satyam.life/ . It has two routes (one for creating cookie, other for sending back cookie received in request header).
Again, I am not having any issue when both servers are running on localhost. I am using seperate EC2 ubuntu 20.04 machines for deployment.
Logs
No response
System Info
System:
OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
CPU: (1) x64 Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
Memory: 223.23 MB / 978.57 MB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.8.0 - ~/.local/share/pnpm/node
npm: 7.21.0 - ~/.local/share/pnpm/npm
npmPackages:
@sveltejs/adapter-node: ^1.0.0-next.44 => 1.0.0-next.44
@sveltejs/kit: next => 1.0.0-next.162
svelte: ^3.34.0 => 3.42.4
Severity
serious, but I can work around it
Additional Information
Work around is calling an endpoint from load fetch and using headers in endpoint. But this is a serious issue and hope it gets fixed soon. Thanks.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
I don’t get it. So a cookie on
.example.com
is not forwarded when my sveltekit server is onwebapp.example.com
and my API is onapi.example.com
.This is a bit annoying. How would I handle this in the load function then?
Edit: found this discussion: #4750
Thanks I got it. I changed the backend url to api.expense.satyam.life and it works.