I created a minimal curl example to reproduce the error, one with --data and one without to narrow down the issue
curl 'http://localhost:3000/api/test' -H 'Content-Type: application/json' -H 'Cookie: ....'
curl 'http://localhost:3000/api/test' -H 'Content-Type: application/json' -H 'Cookie: ....' --data '{"foo": "bar"}'
In my middleware I can see that req.body is an IncomingStream with data and null without. When there is an IncomingStream my [nextAuth...].ts doesn't trigger the jwt callback and thus I get 401's from my endpoint. I'm super confused - any ideas what could be causing this?
In the failure case I also see this, but the docs and lots of googling haven't helped me narrow down the cause.
[next-auth][error][CLIENT_FETCH_ERROR]
https://next-auth.js.org/errors#client_fetch_error undefined {
error: {},
url: 'http://localhost:3000/api/auth/session',
message: undefined
}
Thanks in advance! I'll attach the code below
This is a list of errors output from NextAuth.js.