Next.js Discord

Discord Forum

Do I need to send accessToken to internal API when calling it from a server component?

Unanswered
West African Lion posted this in #help-forum
Open in Discord
Avatar
West African LionOP
I have some internal APIs consumed from the clientSide but also form the serverSide. When working from the server side with fetch do I need to send the accessToken?
Thanks 🙂

2 Replies

Avatar
josh
Depends, we could do with some more context.

Is the access token specific to the user somehow or is it for the whole app?

If it's for the whole app, you can still access an env variable on the server side in the same way: process.env.NEXT_PUBLIC_<YOUR_VAR>
Avatar
West African LionOP
Yes, specific to the user. Thanks 🙂