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.

example code error `UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'protection' of undefined`

See original GitHub issue

Your question I tried example code, in my project, I got this error.

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'protection' of undefined

I just copied it except omitting the database. What should I fix?

What are you trying to do I want to authenticate on Github.

Reproduction node v14.13.0 yarn 1.22.10 next 10.0.6 next-auth 3.14.1

// /src/pages/api/auth/[...nextauth].ts
import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'

export default NextAuth({
  // Configure one or more authentication providers
  providers: [
    Providers.GitHub({
      clientId: process.env.GITHUB_ID,
      clientSecret: process.env.GITHUB_SECRET,
    }),
  ],
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dcolonvcommented, Apr 11, 2021

Temporal solution to keep working before merge of the fix, you can go to /node_modules/next-auth/dist/server/index.js:128 and add provider && ... manually on the if

2reactions
4ortytwocommented, Apr 11, 2021

Started having this error all of a sudden. Manually edited check for provider as proposed by @dcolonv’s PR just to keep working. Hoping it will be merged soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'cache' of undefined - Stack ...
but once run with this line included, I get this error. (node:10388) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'cache' ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >
What is "TypeError: Cannot read property 'state' of undefined"?
The error message says that you don't have the state property on an undefined object. To decode this, we have to understand the...
Read more >
How To Fix Cannot read Property '0' of Undefined in JS
It happens to the best of us. Double check your code and make sure that the array, string, or object literal you are...
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