question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

defaultCookies is not defined

See original GitHub issue

Question 💬

Hi I’m using next-auth version: 3.27.3 I suddenly got this error while running my app. Anyone encountered this? Thank you.

error - unhandledRejection: ReferenceError: defaultCookies is not defined
    at C:\Users\MAGICSOFT Mike\Desktop\NEW MAGICSOFT\crd-prototype\node_modules\next-auth\dist\server\index.js:102:9
    at new Promise (<anonymous>)
    at NextAuthHandler (C:\Users\MAGICSOFT Mike\Desktop\NEW MAGICSOFT\crd-prototype\node_modules\next-auth\dist\server\index.js:67:10)
    at NextAuth (C:\Users\MAGICSOFT Mike\Desktop\NEW MAGICSOFT\crd-prototype\node_modules\next-auth\dist\server\index.js:299:10)
    at __WEBPACK_DEFAULT_EXPORT__ (C:\Users\MAGICSOFT Mike\Desktop\NEW MAGICSOFT\crd-prototype\.next\server\pages\api\auth\[...nextauth].js:188:128)
    at Object.apiResolver (C:\Users\MAGICSOFT Mike\Desktop\NEW MAGICSOFT\crd-prototype\node_modules\next\dist\server\api-utils.js:101:15)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async DevServer.handleApiRequest (C:\Users\MAGICSOFT Mike\Desktop\NEW MAGICSOFT\crd-prototype\node_modules\next\dist\server\next-server.js:775:9)
    at async Object.fn (C:\Users\MAGICSOFT Mike\Desktop\NEW MAGICSOFT\crd-prototype\node_modules\next\dist\server\next-server.js:666:37)

How to reproduce ☕️

npm run dev

Contributing 🙌🏽

No, I am afraid I cannot help regarding this

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

19reactions
balazsorban44commented, Jun 14, 2022

Hi, v3 is an unmaintained version. Please upgrade to v4 and report back if you still experience the issue.

5reactions
fabiencommented, Jun 14, 2022

Same error here, nothing changed on the codebase (and using older v3), my client just did another deploy due to CMS updates. This is unacceptable.

[POST] /api/auth/_log
20:14:15:50
2022-06-14T18:14:18.805Z	8563085b-526b-4d39-bb06-b37d643e1344	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"ReferenceError: defaultCookies is not defined","reason":{"errorType":"ReferenceError","errorMessage":"defaultCookies is not defined","stack":["ReferenceError: defaultCookies is not defined","    at /var/task/node_modules/next-auth/dist/server/index.js:102:9","    at new Promise (<anonymous>)","    at NextAuthHandler (/var/task/node_modules/next-auth/dist/server/index.js:67:10)","    at NextAuth (/var/task/node_modules/next-auth/dist/server/index.js:299:10)","    at /var/task/.next/server/chunks/5599.js:546:64","    at Object.apiResolver (/var/task/node_modules/next/dist/server/api-utils/node.js:185:15)","    at processTicksAndRejections (internal/process/task_queues.js:95:5)","    at async NextNodeServer.runApi (/var/task/node_modules/next/dist/server/next-server.js:395:9)","    at async Object.fn (/var/task/node_modules/next/dist/server/base-server.js:496:37)","    at async Router.execute (/var/task/node_modules/next/dist/server/router.js:226:36)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: ReferenceError: defaultCookies is not defined","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:412:35)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:96:32)"]}
Unknown application error occurred

EDIT I downgraded next-auth explicitly to version 3.29.3 (was ^3.29.3 before) and now it works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next-Auth : defaultCookies is not defined - Stack Overflow
I'm using next/auth version: 3.27.3 I suddenly got this error while running my app. Anyone encountered this? error - unhandledRejection: ...
Read more >
Errors - NextAuth.js
Errors. This is a list of errors output from NextAuth.js. All errors indicate an unexpected problem, you should not expect to see errors....
Read more >
WebClient.Builder (Spring Framework 6.0.3 API)
Provides access to every defaultCookie(String, String...) declared so far with the possibility to add, replace, or remove. WebClient.Builder.
Read more >
Work with SameSite cookies in ASP.NET - Microsoft Learn
Setting it equal to (SameSiteMode)(-1) indicates that no SameSite header should be included on the network with the cookie. The HttpCookie.
Read more >
Upcoming changes in cookie handling in Google Chrome
"SameSite by default cookies"; "Cookies without SameSite must be secure ... When this attribute is not defined, currently all browsers allow ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found