mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #555] [MERGED] fix: align next/headers cookie path semantics #672
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#672
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/555
Author: @NathanDrake2406
Created: 3/16/2026
Status: ✅ Merged
Merged: 3/16/2026
Merged by: @james-elicx
Base:
main← Head:fix/cookies-path-default-delete-options📝 Commits (2)
9a63bafAlign next/headers cookie path semantics2031626Address cookie path review feedback📊 Changes
4 files changed (+122 additions, -12 deletions)
View changed files
📝
packages/vinext/src/shims/headers.ts(+19 -7)📝
tests/app-router.test.ts(+2 -2)📝
tests/nextjs-compat/app-routes.test.ts(+2 -2)📝
tests/shims.test.ts(+99 -1)📄 Description
Summary
This aligns the mutable
next/headerscookie shim with Next.js cookie semantics in two places:cookies().set()now defaultsPath=/, andcookies().delete()now accepts an options object withpathanddomain.What Changed
cookies().set()to emitPath=/when no path is providedcookies().delete({ name, path, domain })and emit an expired cookie header with those attributesMax-Age=0tests/shims.test.tsfor both behaviorsWhy It Matters
Without the default path,
cookies().set("name", "value")scopes the cookie to the current request path instead of/, which differs from Next.js and can break session visibility across routes. Without the object-form delete, vinext cannot reliably clear cookies that were originally set on a non-default path or domain.Risks Or Limits
This only changes the mutable
next/headerscookie surface inshims/headers.ts. It does not changeNextResponse.cookiesinnext/server. The deletion header now uses an expiredExpires=value, matching upstreamResponseCookies.delete()behavior.Verification
./node_modules/.bin/vp test run tests/shims.test.ts -t "next/headers phase-aware cookies"./node_modules/.bin/vp test run tests/nextjs-compat/app-routes.test.ts tests/nextjs-compat/set-cookies.test.ts tests/app-router.test.tsgit diff --check🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.