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
setCookie
example in docs incorrectly handles expires
and maxAge
#28453
Comments
This is a good point in my opinion, that ties in with #36478 (comment) |
Hi, this is my first open source contribution. I have raised a pull request for this issue:#36870 . Please review my changes and let my know any changes that I ought to do. Thanks |
fixes #28453 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [X] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [X] Make sure the linting passes by running `yarn lint`
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
The example code for a setCookie function (https://nextjs.org/docs/api-routes/api-middlewares#extending-the-reqres-objects-with-typescript) shows the maxAge option being divided by 1000.
I believe the function should be:
The max-age attribute for Set-Cookie is in seconds. Therefore I believe there's a few changes that are required to the middle conditional:
maxAge
is numerical.Date.now
provides time in milliseconds, we need to multiplyoptions.maxAge
by 1000.options.maxAge
does not require altering as it can be passed on in seconds to theserialize
function which expects it in seconds:Originally posted by @will-stone in #27617 (comment)
The text was updated successfully, but these errors were encountered: