fix: support cookie v2.x#361
Merged
Merged
Conversation
v2 removed the / exports in favour of /, which broke every route that sets or reads a cookie (all requests returned 500). - adapt to the new cookie@2 API while keeping the historic / signatures for @fastify/cookie's own public API (fastify.parseCookie, fastify.serializeCookie, module.exports.parse/serialize) - bump the dependency to ^2.0.0 - fix README links that pointed to now-outdated v1 anchors
ac9e996 to
97dcc90
Compare
Member
|
A lot of stylistic changes in here? Likewise I wouldn't class this as a fix, it's just a dependency update isn't it? |
Member
Author
Is a dependency update that required some changes due to the renaming of certain function |
ilteoood
reviewed
Jul 9, 2026
climba03003
approved these changes
Jul 9, 2026
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.
Proposal:
cookie v2.x(v2.0.0: https://github.com/jshttp/cookie/releases/tag/v2.0.0).cookiev2 is a breaking release: it drops theparse(str, opts)andserialize(name, value, opts)exports entirely, replacing them withparseCookie(str, opts)andstringifySetCookie({ name, value, ...opts }, encodeOpts).Since
index.jsstill calledcookie.parse(...)/cookie.serialize(...), every call becameundefined is not a function, causing every route that touches cookies (setting, clearing, or parsing) to respond with a here: 500, see test errors here: https://github.com/fastify/fastify-cookie/actions/runs/28953073061/job/85904705783?pr=356#step:5:763 .Change
parseCookie/stringifySetCookiefromcookie v2.xand wrap them in localparse(str, opts)/serialize(name, value, opts)helpers that preserve the old 3-argument call shape.setCookie,clearCookie, request cookie parsing, theserializeCookie/parseCookiedecorators, and themodule.exports.serialize/.parsealiases) through these wrappers, so the plugin's public API is unchanged.cookieto^2.0.0inpackage.json.cookiev1's old anchor names.