-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Unable to read response cookies until onSend #269
Comments
So you want a getCookie function. |
A |
You either use setCookie or you use .header('set-cookie'). Mxing both is not recommended. If you are willing to provide a PR, which is not breaking with the current test set, then I guess we can discuss it. |
There could indeed be a getCookie method |
We're using business logic plugins from different teams. They don't know if fastify-cookie is used inside the final server. So how can one know how to read response cookies ? Why isn't it a good thing to mix both ways ? I'm not sure I'll have time for the PR, but I'll try :) |
Define the dependencies for your plugins (https://github.com/fastify/fastify-plugin#dependencies) so that your plugins are guaranteed to have access to the methods they require. As for the issue at hand, I would say that the reply is missing the equivalent: Line 140 in 7ad33bc
|
Prerequisites
Fastify version
4.25.2
Plugin version
9.2.0
Node.js version
20.9.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
20.04
Description
Hello,
In my route handler, if I use
reply.setCookie
to set a response cookie, I'm unable to read it inside my handler by callingreply.getHeader('set-cookie')
. However, I can read my resp cookie later in the lifecycle (onSend and onResponse).I need to read it inside my handler. Maybe it's working as intended or I missed something ?
Steps to Reproduce
Server :
The following curl
curl -i http://localhost:8080/
gives me this :And server logs :
Expected Behavior
I expect I can write/read response cookies through the plugin the "same way" I do through
reply.header('set-cookie', ...)
.I would like the plugin to modify the
set-cookie
response header as soon as i call thereply.setCookie
method.I find it misleading to "hide" the cookies that will be sent until the onSend lifecycle step.
The text was updated successfully, but these errors were encountered: