Little stuck while working on secrets though. I set my secret using flyctl secrets set NAME=VALUE. flyctl secrets list shows NAME as well.
In my nodejs, I use process.env.NAME. That works great locally (when setting my key using export in my terminal), but doesn’t work when deployed. Logging process.env on the deployed server, shows that NAME is not available.
How should I access NAME from my nodejs typescript server, if process.env.NAME is not the way to go?
Did you set the secret with an uppercase name? We’ve seen Node not pick secrets up with lowercase names before. flyctl secrets list should show the name in the case you used.
I still cannot seem to get the job done
Looks like I can run the example that you provide. That works!
I used the env name ‘google’, which didn’t work. Unsetting it works, setting it will give me a ‘no change detected in secrets’.
Using the env name ‘NAME’, same value, worked.
Hmm, very strange behaviour (or I’m missing something trivial).
In the following code snippet, removing console.log will result in branching into the if-statement. Using console.log results in not branching into the if-statement (which makes sense).
const credentials = process.env.NAME;
console.log(`name: ${process.env.NAME}`);
if (!credentials) {
Thanks for deleting those two secrets, I was able to set a new google value now without an issue. Not sure what went wrong there.
I tried printing the process.env object earlier and it didn’t show either NAME and google (it did include a bunch of other variables though). Looping over the keys and printing those results in the same (not seeing google or NAME).
Printing it explicitly using console.log(process.env.NAME), does show a value. Looks like the ‘google’ secret is still not working correctly. The DIGEST is the same for all 3 (NAME, google, GOOGLE). I am not sure what would be the difference between NAME and the other two if the DIGEST is the same.
While I can definitely make my server work with the NAME variable, I will do some more tests tomorrow to see whether other variables do work (might be useful for you as well haha).