Skip to content

Commit

Permalink
passportAuth — improve error message if req.query.auth is undefined (#…
Browse files Browse the repository at this point in the history
…2766)

(patch)
  • Loading branch information
martinsaxa committed Sep 30, 2021
1 parent 3fb7327 commit 862b21c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nextjs/packages/next/stdlib-server/passport-adapter.ts
Expand Up @@ -101,6 +101,15 @@ export function passportAuth(config: BlitzPassportConfig): NextApiHandler {
middleware.push(secureProxyMiddleware)
}

assert(
req.query.auth,
'req.query.auth is not defined. Page must be named [...auth].ts/js. See more at https://blitzjs.com/docs/passportjs#1-add-the-passport-js-api-route'
)
assert(
Array.isArray(req.query.auth),
'req.query.auth must be an array. Page must be named [...auth].ts/js. See more at https://blitzjs.com/docs/passportjs#1-add-the-passport-js-api-route'
)

if (!req.query.auth.length) {
return res.status(404).end()
}
Expand Down

0 comments on commit 862b21c

Please sign in to comment.