You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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