Repository navigation
fix(helpers): preserve multiple Set-Cookie headers in withCookie - #838
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
Headers.get('set-cookie') joins repeated Set-Cookie headers with a comma, so
withCookie returned DS and DSR as one cookie string. Read each header
separately via getSetCookie (falling back to the combined value on runtimes
without it) and look for the refresh token across all of them.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
🐕 Shuni ReviewNo new issues found. Approval outcome: APPROVED 🤖 Model: Review scope: Full review Reviewed files (2)
🐕 Review complete — View session on Shuni Portal 🐾 🤖 Model: |
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.
Related Issues
No existing issue.
Description
withCookiereadresponse.headers.get('set-cookie')and pushed that single string intocookies.Headers.get()joins repeatedSet-Cookieheaders with a comma, so when Descope returns both theDSandDSRcookies,cookiesholds one combined entry. Forwarding it (as the README middleware does withres.set('Set-Cookie', out.cookies)) sends a singleSet-Cookieheader, and the browser only stores the first cookie; the second one is read as an attribute of the first.This adds a small
getSetCookieshelper that usesHeaders.getSetCookie()when available and falls back to the combined value on runtimes without it (same behaviour as before there). EverySet-Cookieheader becomes its own entry incookies, and the refresh token is looked up across all of them. No comma-splitting is attempted, sinceExpirescontains commas.New test in
lib/index.test.ts: a response with twoSet-Cookieheaders (both withExpires) must come back as two separatecookiesentries, withrefreshJwttaken from the second. It fails onmain(one combined entry) and passes with this change.Must
This PR was prepared with the help of an AI coding assistant (Claude) and submitted on the author's behalf; the change and tests were produced by that assistant.