Back

Updating global env variable from a function

  • 1
  • Functions
  • Web
  • Cloud
gelmuda
4 May, 2024, 20:46

Hi, I have a refresh token function (in nodeJS) for external system. Function is being run with crone every 2h. I have 2 global variables S_TOKEN and S_REFRESH_TOKEN and they are initially set to correct values. In my function I use: const refreshToken = process.env.S_REFRESH_TOKEN; with http request and I can see I am getting a correct pair of new token and refresh token. Then I try to update global env values with: process.env.S_TOKEN = responseData.token; process.env.S_REFRESH_TOKEN = responseData.refreshToken; Everything runs without errors, but when I check global variables they are not changing, but every 2h tokens get refreshed, but when I check logs it seems like S_TOKEN and S_REFRESH_TOKEN are became local env variables (although I have empty function env variables box in function settings).

TL;DR
Developers are trying to update global environment variables in a NodeJS function but even though the code seems correct, the variables are not updating as expected. The solution might be to restart the server or container after updating the global environment variables for the changes to take effect.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more