Access request headers from events
callbacks
#8991
-
We use the Is this possible in NextAuth.js? I'm using version |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
If you are using the app router, I believe you can get headers using the Below is the reference in the code: I think it could be a good addition to the library, since having access to headers (and cookies, for that matter) in the callbacks might make certain tasks easier. |
Beta Was this translation helpful? Give feedback.
If you are using the app router, I believe you can get headers using the
headers()
function fromnext/headers
. Besides that, there doesn't appear to be a way to access the headers from that callback.Below is the reference in the code:
OAuth signIn callback found here.
If you are willing to delve into your
node_modules
and use something likepatch-package
, you could make the changes necessary yourself (the function that calls the callbacks does have access to headers), but this might be a bit tricky.I think it could be a good addition to the library, since having access to headers (and cookies, for that matter) in the callbacks might make certain tasks easier.