diff --git a/packages/next/server/web/spec-extension/cookies.ts b/packages/next/server/web/spec-extension/cookies.ts index 3d60c5499d22..f6cf48029a7b 100644 --- a/packages/next/server/web/spec-extension/cookies.ts +++ b/packages/next/server/web/spec-extension/cookies.ts @@ -5,8 +5,7 @@ const normalizeCookieOptions = (options: CookieSerializeOptions) => { options = Object.assign({}, options) if (options.maxAge) { - options.expires = new Date(Date.now() + options.maxAge) - options.maxAge /= 1000 + options.expires = new Date(Date.now() + options.maxAge * 1000) } if (options.path == null) { diff --git a/test/unit/web-runtime/cookies.test.ts b/test/unit/web-runtime/cookies.test.ts index 7ee620cd7018..7eca76da0d45 100644 --- a/test/unit/web-runtime/cookies.test.ts +++ b/test/unit/web-runtime/cookies.test.ts @@ -55,7 +55,7 @@ it('.set with options', async () => { const options: CookieSerializeOptions = { path: '/', - maxAge: 1000 * 60 * 60 * 24 * 7, + maxAge: 60 * 60 * 24 * 7, httpOnly: true, sameSite: 'strict', domain: 'example.com', @@ -65,7 +65,7 @@ it('.set with options', async () => { expect(options).toStrictEqual({ path: '/', - maxAge: 1000 * 60 * 60 * 24 * 7, + maxAge: 60 * 60 * 24 * 7, httpOnly: true, sameSite: 'strict', domain: 'example.com',