vercel / remix

Build Better Websites. Create modern, resilient user experiences with web fundamentals.
https://remix.run
MIT License
62 stars 21 forks source link

Cannot return multiple "Set-Cookie" headers in actions/loaders #130

Open cody-dot-js opened 1 week ago

cody-dot-js commented 1 week ago

I am noticing that when I run remix vite locally with single fetch, I can return multiple Set-Cookie headers in actions and loaders. If I do something like:

const headers = new Headers([
  ["Set-Cookie", "aaa=1"],
  ["Set-Cookie", "bbb=1"],
  ["Set-Cookie", "ccc=1"],
]);

return redirect("/somewhere", { headers });

I see all three Set-Cookie headers sent to the browser.

However, when deployed to vercel, only the last Set-Cookie header "ccc=1" is sent to the browser! I am not sure at this time if it's a purely vercel serverless runtime bug or a wombo combo with vercel + remix vite + single-fetch.

I am using node 20 lts and the latest versions of remix, vite, and the vercel preset.

I am working on producing a minimal repro case for y'all and will update this issue when I have one. I will also investigate if it's a problem with the classic remix compiler and remix vite without single fetch enabled.

EDIT: Reproduction repo: https://github.com/cody-dot-js/remix-vercel-set-cookie-repro Reproduction deployment: https://remix-vercel-set-cookie-repro.vercel.app/

Expectation: I see three cookies set when I visit the index page of this app: aaa=loader, bbb=loader, and ccc=loader.

I see three Set-Cookie headers in the network tab for the action response.

Reality: Locally, I see the three cookies. However, in the vercel deployment, I only see the last cookie ccc=loader

Screenshots:

Google Chrome 2024-09-10 13 57 33

Google Chrome 2024-09-10 13 59 02

cody-dot-js commented 1 week ago

Looks like it's a bug w/ remix single fetch on vercel!

Repro here: https://github.com/cody-dot-js/remix-vercel-set-cookie-repro/pull/1

Deploy: https://remix-vercel-set-cookie-rep-git-fcb2b2-codyjs-projects-9c03697f.vercel.app/

image
TooTallNate commented 11 hours ago

Thanks for the repro. I can confirm this is currently an issue on Vercel when using the Node.js native Headers (which is indeed the case with singleFetch). We are looking into it.