Getting user session from NextJS server action #65876
Unanswered
afsal983
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
My NextJs 14 application uses app router for admin front end. The request flow for login is nextjs client -> nextjs api -> golang API to get the JWT token and from there new flow for actual data will be started nextjs client -> nextjs api -> golang API. Being a multi tenant supported admin portal, Golang API uses user token to extract data for respective organization. As long as the front end request originate from client side, this architecture works perfectly as user token can be extracted at next JS API level from the cookie and use in the fetch request towards Golang API.. However, this architecture miserably fails when nextJs server action pulls the data from golang API as there is no cookie available for the request originates from the server.
Apparently what I am looking for is to somehow get the user session information at server action in order to be used in the fetch request towards golang API. Please shed some lights.
Note: since the login is happening via nextjs APIs which runs at the server side, I can inject into a database. But how will identify which token to be used for subsequent server action fetch request. here is my problem.
Beta Was this translation helpful? Give feedback.
All reactions