Error handler invoked when an exception occurs during execution of the sign-in, callback, sign-out, or userinfo endpoints.
In the App Router, you must either return a NextResponse or throw an error. Otherwise, the request will remain unresolved. In the Pages Router, you must send a response (for example, res.send() or res.json()) after handling the error, or the request will hang.
NextResponse
res.send()
res.json()
Error handler invoked when an exception occurs during execution of the sign-in, callback, sign-out, or userinfo endpoints.