Replies: 1 comment
-
I'm also a bit confused. According to the network tab, it is trying to fetch the state from /api/auth/session but I don't know what to do. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
sign in works fine, if i go to the route manually in browser for example:
localhost:3000/api/resource i get the json no problem.
BUT
if do a fetch/axios call from a server component to the same route localhost:3000/api/resource the session is null.
I have a postman collection that I imported, when i login to nextauth and then hit the endpoint I get the data no problem. I see postman is setting up 3 cookies for localhost authjs.callback, authjs.csrf-token, authjs.session-token.
where do i get access to data to setup the cookie on the api calls? I scoured the docs and cannot find an example.
I am doing a workaround, where im getting the session, then passing the api token as an argument and then attaching to header, parsing in route.ts and re-attaching to header to the external api, which is fine, but it would be great if i could just call auth() to get session and grab the token without messing with manually adding to headers on every call.
snippet of ideal route.ts auth handling and attached is a snip of the postman cookies that get set
Beta Was this translation helpful? Give feedback.
All reactions