How do I make APIs calls between django and Next.js 13 while being on the server side?

I am making a chat app using nextjs 13 and django as backend.

But I'm stuck in authentication and other api calls which requires bearer.

If I logged in then how can I save the tokens to the server because sometimes I want to make api calls from sever and may this requires bearer.

Also if I'm doing it from client If I logged in from client directly to the api it'll save the cookies but If how do I check before requests that if it's expired or any problems

Thanks 😊

I made a wrapper using next-auth and calling login function from signIn of next-auth. This saves session in the server but when it's comes to client I would need bearer from server and I have to use until useSession available.

Back to Top