mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #147] [CLOSED] fix: include credentials in RSC fetch calls and match better-auth error format #348
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#348
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/147
Author: @CodyBontecou
Created: 2/27/2026
Status: ❌ Closed
Base:
main← Head:main📝 Commits (3)
fd23615fix: include credentials in RSC fetch calls for auth cookie support1ae8759fix: add credentials to prefetch and router fetch callsa4ec5e7fix: match error message format expected by better-auth📊 Changes
4 files changed (+21 additions, -6 deletions)
View changed files
📝
packages/vinext/src/server/app-dev-server.ts(+8 -2)📝
packages/vinext/src/shims/headers.ts(+11 -3)📝
packages/vinext/src/shims/navigation.ts(+1 -0)📝
packages/vinext/src/shims/router.ts(+1 -1)📄 Description
Summary
Fixes #85 - Authentication cookies not sent during client-side RSC navigation
Problem
Two issues were causing authentication to fail with better-auth:
Client-side RSC fetch calls were missing
credentials: 'include'- When navigating between pages, the RSC fetch requests didn't include cookies, causing authenticated users to appear logged out.Error message format incompatibility with better-auth - better-auth's
nextCookies()plugin catches errors starting with "`cookies` was called outside a request scope." to gracefully handle unavailable cookie context. Vinext was throwing a different error message, causing better-auth to fail instead of gracefully degrading.Changes
1. Add
credentials: 'include'to all client-side fetch callsapp-dev-server.ts: Server actions, RSC hydration fallback, navigation fetch, HMR refreshnavigation.ts: Prefetch requestsrouter.ts: Pages Router navigation2. Fix error message format for better-auth compatibility
Changed
cookies()andheaders()error messages to start with the prefix that better-auth expects:Testing
Tested with a production app using better-auth on Cloudflare Workers:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.