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

Allow setting multiple cookies in Netlify adapter #3092

Merged
merged 4 commits into from
Apr 12, 2022

Conversation

matthewp
Copy link
Contributor

Changes

Testing

Test added

Docs

N/A, bug fix

@changeset-bot
Copy link

changeset-bot bot commented Apr 12, 2022

🦋 Changeset detected

Latest commit: 15cd9fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/netlify Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: integration Related to any renderer integration (scope) test labels Apr 12, 2022
Copy link
Member

@FredKSchott FredKSchott left a comment

Choose a reason for hiding this comment

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

LGTM with a doc comment

body: responseBody,
};

// Special-case set-cookie which has to be set an different way :/
Copy link
Member

Choose a reason for hiding this comment

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

so strange. mind expanding a bit on why exactly this is needed, for future readers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah sure, the tldr here is that the Fetch API concatenates headers and comma-separates them when you try to get them with headers.get('foo'). Set-Cookie is the only header that doesn't work comma-separated and must be set with multiple Set-Cookie headers. Fetch does not have an API for that, because there's no need for it in the browser.

Luckily node-fetch has a special API for this use-case and Netlify will always use that polyfill so its safe to use. Other adapters will have to do it different ways, since there is no standard.

For reference (with various host providers weighing in): whatwg/fetch#973

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a comment with a link to that issue.

@FredKSchott
Copy link
Member

perfect, thanks! LGTM to merge

@matthewp matthewp merged commit a5caf08 into main Apr 12, 2022
@matthewp matthewp deleted the netlify-multiple-cookies branch April 12, 2022 20:50
@github-actions github-actions bot mentioned this pull request Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: Unable to set multiple cookies
2 participants