Skip to content
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

Display error if no [...nextauth].js found #678

Merged
merged 3 commits into from
Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ async function NextAuth (req, res, userSuppliedOptions) {
// safe to return and that no more data will be sent.
const done = resolve

if (!req.query.nextauth) {
const error = 'Cannot find [...nextauth].js in pages/api/auth. Make sure the filename is written correctly.'

logger.error('MISSING_NEXTAUTH_API_ROUTE_ERROR', error)
res
.status(500)
.end(
`Error: ${error}`
)
return done()
}

const { url, query, body } = req
const {
nextauth,
Expand Down
7 changes: 7 additions & 0 deletions www/docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ If you are using a Credentials Provider, NextAuth.js will not persist users or s
In _most cases_ it does not make sense to specify a database in NextAuth.js options and support a Credentials Provider.

#### CALLBACK_CREDENTIALS_HANDLER_ERROR

---

### Session Handling
Expand Down Expand Up @@ -127,3 +128,9 @@ They all indicate a problem interacting with the database.
This error occurs when the Email Authentication Provider is unable to send an email.

Check your mail server configuration.

#### MISSING_NEXTAUTH_API_ROUTE_ERROR

This error happens when `[...nextauth].js` file is not found inside `pages/api/auth`.

Make sure the file is there and the filename is written correctly.