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

fix(adapter-nextjs): duplicate response Set-Cookie headers in pages router #13765

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

HuiSF
Copy link
Member

@HuiSF HuiSF commented Aug 28, 2024

Description of changes

Fixing duplicate Set-Cookie header may be added with in Next.js Page Router.

Issue #, if available

Description of how you validated changes

  • Unit tests
  • Manual testing with Next.js sample app
  • E2E test with checking response Set-Cookie headers

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@HuiSF HuiSF changed the base branch from main to release August 28, 2024 21:13
@HuiSF HuiSF requested review from a team as code owners August 28, 2024 21:13
@HuiSF HuiSF marked this pull request as draft August 28, 2024 21:13
Array.isArray(existingSetCookieValues) &&
existingSetCookieValues.findIndex(
cookieValue =>
cookieValue.startsWith(`${encodedName}=`) &&
Copy link
Member

Choose a reason for hiding this comment

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

naive question: why not just check startsWith(`${encodedName}=${value};`) here?

Copy link
Member Author

@HuiSF HuiSF Aug 28, 2024

Choose a reason for hiding this comment

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

As value may change when there were back to back token refreshes happened, e.g. a request going through the middleware and the page and tokens were being refreshed in both places. In this case we keep the very first refresh.

@HuiSF HuiSF force-pushed the hui/fix/adapter-nextjs/pages-cookies branch 2 times, most recently from df00288 to 2ec0b64 Compare August 28, 2024 21:57
@HuiSF HuiSF marked this pull request as ready for review August 28, 2024 21:59
@HuiSF HuiSF requested a review from atierian August 28, 2024 21:59
Copy link
Contributor

@jimblanc jimblanc left a comment

Choose a reason for hiding this comment

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

LGTM

@HuiSF HuiSF merged commit 3fedf63 into release Sep 3, 2024
31 of 40 checks passed
@HuiSF HuiSF deleted the hui/fix/adapter-nextjs/pages-cookies branch September 3, 2024 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants