fix(eventsource): set credentials to "include" when withCredentials is true#5379
Open
AliMahmoudDev wants to merge 2 commits into
Open
fix(eventsource): set credentials to "include" when withCredentials is true#5379AliMahmoudDev wants to merge 2 commits into
AliMahmoudDev wants to merge 2 commits into
Conversation
…s true When withCredentials is true, the credentials mode was incorrectly set to 'omit' instead of 'include', causing cookies and auth headers to not be sent with EventSource requests. Fixes nodejs#5378
The sameSite field type was incorrectly documented as "String" instead
of "Strict" in the Cookie interface. The source code correctly defines
it as {"Strict"|"Lax"|"None"}.
Fixes nodejs#5380
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5379 +/- ##
=======================================
Coverage 93.25% 93.25%
=======================================
Files 110 110
Lines 36752 36752
=======================================
Hits 34274 34274
Misses 2478 2478 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This relates to...
Fixes #5378
Also fixes #5380 (docs: Cookie sameSite type typo)
Rationale
When
withCredentials: trueis passed to the EventSource constructor, the underlying fetch request should setcredentialsto"include"per the WHATWG EventSource spec.Currently, the ternary on line 168 evaluates to
"omit"whencorsAttributeStateisUSE_CREDENTIALS, because the condition checks for"anonymous"and falls through to the else branch.Changes
Bug Fixes
"omit"to"include"in the credentials ternary inEventSourceconstructor"String"to"Strict"Testing
Verified that
withCredentials: truenow correctly sets credentials to"include"in the request options.