Link to the code that reproduces this issue
https://github.com/c0d3rm0n/test-set-cookies
To Reproduce
I'm creating an app that uses third party libraries that use Go and set / send their cookies in raw format, and they expect to receive them in the same format.
I use those services in my server actions, and then I have to set the cookies they send inside of response headers. As result of this action, the cookie(s) sent to my server will be set in my browser.
However, the function cookies().set({...my_cookie}) from next/headers will encode the cookie and the value set will not match the original one, causing my calls to those 3rd party libs to fail or give error.
From what I could find, encode should be an option of Cookie, and in next.js modules it is possible to find an interface that includes it (CookieSerializeOptions) but then, the other interfaces that use it don't include encode... So, even if I try to set a cookie like cookies().set({...my_cookie, encode: String}) the browser record will be encoded.
The same happens in Middleware, using nextResponse.cookies.set({...my_cookie}).
Current vs. Expected behavior
I would like to be able to set a cookie and define the encoding function in it's options.
For example, the function cookies().set({...my_cookie, encode: String}) should accept encode as option and save a value like
qwerty123=
and not
qwerty123%3D
as it is saving at the moment...
Provide environment information
Operating System:
Platform: linux
Arch: x64
Binaries:
Node: 20.11.0
npm: 10.2.4
Relevant Packages:
next: 14.1.4
eslint-config-next: 14.1.4
react: 18.2.0
react-dom: 18.2.0
typescript: 5.4.4
Next.js Config:
output: standalone
Which area(s) are affected? (Select all that apply)
Middleware / Edge (API routes, runtime)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
Link to the code that reproduces this issue
https://github.com/c0d3rm0n/test-set-cookies
To Reproduce
I'm creating an app that uses third party libraries that use Go and set / send their cookies in raw format, and they expect to receive them in the same format.
I use those services in my server actions, and then I have to set the cookies they send inside of response headers. As result of this action, the cookie(s) sent to my server will be set in my browser.
However, the function cookies().set({...my_cookie}) from next/headers will encode the cookie and the value set will not match the original one, causing my calls to those 3rd party libs to fail or give error.
From what I could find, encode should be an option of Cookie, and in next.js modules it is possible to find an interface that includes it (CookieSerializeOptions) but then, the other interfaces that use it don't include encode... So, even if I try to set a cookie like cookies().set({...my_cookie, encode: String}) the browser record will be encoded.
The same happens in Middleware, using nextResponse.cookies.set({...my_cookie}).
Current vs. Expected behavior
I would like to be able to set a cookie and define the encoding function in it's options.
For example, the function cookies().set({...my_cookie, encode: String}) should accept encode as option and save a value like
qwerty123=
and not
qwerty123%3D
as it is saving at the moment...
Provide environment information
Which area(s) are affected? (Select all that apply)
Middleware / Edge (API routes, runtime)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response