Thanks to visit codestin.com
Credit goes to github.com

Skip to content

docs: clarify getAccessToken req/res usage in Route Handlers with cus…#2577

Merged
Piyush-85 merged 3 commits into
mainfrom
SDK-8101
Apr 2, 2026
Merged

docs: clarify getAccessToken req/res usage in Route Handlers with cus…#2577
Piyush-85 merged 3 commits into
mainfrom
SDK-8101

Conversation

@Piyush-85
Copy link
Copy Markdown
Contributor

Summary

Adds documentation clarifying the correct getAccessToken usage in App Router
Route Handlers that need to refresh the session and set additional cookies
on a controlled NextResponse.

Problem

When a Route Handler calls getAccessToken({ refresh: true }) without req/res
and then constructs a new NextResponse() to append custom cookies, the refreshed
session Set-Cookie headers are missing from the returned response. They were
written to Next.js's internal cookies() store — a separate cookie jar from the
manually constructed response object.

This is not a code bug — the SDK correctly serializes all cookie attributes
(Domain, SameSite, Secure, etc.) in both code paths.

Fix

Documentation only. Added a new example and [!IMPORTANT] callout under
"Forcing Access Token Refresh" in EXAMPLES.md explaining that the explicit
getAccessToken(req, res, { refresh: true }) signature must be used whenever a
Route Handler needs both the refreshed session cookies and custom cookies on the
same returned NextResponse.

Changes

  • EXAMPLES.md — new subsection "App Router Route Handlers — Refresh + Custom Response Headers/Cookies"

@Piyush-85 Piyush-85 requested a review from a team as a code owner March 30, 2026 05:46
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.48%. Comparing base (d1fe0b8) to head (28052c5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2577   +/-   ##
=======================================
  Coverage   90.48%   90.48%           
=======================================
  Files          53       53           
  Lines        6684     6684           
  Branches     1403     1403           
=======================================
  Hits         6048     6048           
  Misses        624      624           
  Partials       12       12           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tusharpandey13
Copy link
Copy Markdown
Contributor

LGTM

@Piyush-85 Piyush-85 merged commit 1188193 into main Apr 2, 2026
9 checks passed
@Piyush-85 Piyush-85 deleted the SDK-8101 branch April 2, 2026 10:59
This was referenced Apr 7, 2026
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.

3 participants