Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

fix: sending cookies in regional remix server with polyfills #709

Merged
merged 5 commits into from
Jul 18, 2024

Conversation

luke-rucker
Copy link
Contributor

the fix to sending multiple cookies merged yesterday #702 does not work when remix polyfills are installed. they are missing the getSetCookie method amongst a few other issues detailed here. this fixes that

const cookies = [];
for (let [key, value] of headers.entries()) {
if (key === "set-cookie") {
cookies.push(value);
Copy link

@alfredsgenkins alfredsgenkins Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not cookies be accumulated in the following format?

`${key}=${value}`

Based on this MDN example it should be.

headers.getSetCookie();
// Returns ["name1=value1", "name2=value2"]

AWS appears to expect the cookies in key=value format, as seen from this example:

"cookies": [
  "s_fid=7AABXMPL1AFD9BBF-0643XMPL09956DE2",
  "regStatus=pre-register"
],

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so yes, but in this case the key is not the name of the cookie, but rather the key of the header. the value will contain the whole cookie header

const cookies = [];
for (let [key, value] of headers.entries()) {
if (key === "set-cookie") {
cookies.push(value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same case here.

@thdxr thdxr merged commit 7e07d41 into sst:dev Jul 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants