Ha! Fixed it!
For anyone interested:
In your [...auth0].js
file you need to add custom callback handling like so:
const authOptions = {
async callback(req, res) {
try {
await handleCallback(req, res, { afterCallback })
} catch (error) {
console.log(error)
res.status(error.status || 500).end(error.message)
}
},
}
export default handleAuth(authOptions)
The magic sauce is happening in the catch block where it will handle the denial of service correctly. For me I will handle it by login out the user and sending it to the root route.
Thanks to anyone that looked at this!