diff --git a/docs/api-routes/request-helpers.md b/docs/api-routes/request-helpers.md index 28be26d66cf4273..3a3f6a0e83e6ac7 100644 --- a/docs/api-routes/request-helpers.md +++ b/docs/api-routes/request-helpers.md @@ -128,7 +128,8 @@ import { setCookie } from '../../utils/cookies' const handler = (req: NextApiRequest, res: NextApiResponse) => { // Calling our pure function using the `res` object, it will add the `set-cookie` header - setCookie(res, 'Next.js', 'api-middleware!') + // Add the `set-cookie` header on the main domain and expire after 30 days + setCookie(res, 'Next.js', 'api-middleware!', { path: '/', maxAge: 2592000 }) // Return the `set-cookie` header so we can display it in the browser and show that it works! res.end(res.getHeader('Set-Cookie')) }