Skip to content

Commit 989d23e

Browse files
jaknasbalazsorban44
andcommitted
feat: Display error if no [...nextauth].js found (#678)
* Display error if no [...nextauth].js found fixes #647 * Log the error and describe it inside errors.md Co-authored-by: Balázs Orbán <info@balazsorban.com>
1 parent 025f33a commit 989d23e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/server/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ async function NextAuth (req, res, userSuppliedOptions) {
3232
// safe to return and that no more data will be sent.
3333
const done = resolve
3434

35+
if (!req.query.nextauth) {
36+
const error = 'Cannot find [...nextauth].js in pages/api/auth. Make sure the filename is written correctly.'
37+
38+
logger.error('MISSING_NEXTAUTH_API_ROUTE_ERROR', error)
39+
res
40+
.status(500)
41+
.end(
42+
`Error: ${error}`
43+
)
44+
return done()
45+
}
46+
3547
const { url, query, body } = req
3648
const {
3749
nextauth,

www/docs/errors.md

+7
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ If you are using a Credentials Provider, NextAuth.js will not persist users or s
7070
In _most cases_ it does not make sense to specify a database in NextAuth.js options and support a Credentials Provider.
7171

7272
#### CALLBACK_CREDENTIALS_HANDLER_ERROR
73+
7374
---
7475

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

129130
Check your mail server configuration.
131+
132+
#### MISSING_NEXTAUTH_API_ROUTE_ERROR
133+
134+
This error happens when `[...nextauth].js` file is not found inside `pages/api/auth`.
135+
136+
Make sure the file is there and the filename is written correctly.

0 commit comments

Comments
 (0)