When i set environment variable as Mosh like “set vidly_jwtPrivateKey=mySecureKey” than I start the application and try to make POST request, I get a console error as " secretOrPrivateKey must have a value " Can anyone know how to solve it ! Thanks in advance
Which operating system is it?
if this is Windows
Do this:
-
Open command line
-
setx vidly_jwtPrivateKey mySecureKey
Then
close your text editor and re-open and start the application, your app should work properly.
To delete:
Search for ‘environment variables’ in your bottom search bar then there you can find ‘Environment Variables’ button which will take you to the UI for managing those stuffs. There is an option to delete the item. Select your key and delete it.
Look into screenshot for better explanation.
i did the same thing that u told to do but still the same
custom-variable-environment.json
{
"jwtPrivateKey" : "vidly_jwtPrivateKey"
}
default.json
{
"jwtPrivateKey":""
}
const token = jwt.sign({ _id: user._id}, config.get('jwtPrivateKey'));
the file name is wrong:
custom-environment-variables.json
for some reason it won’t save it as json file when I write it custom-environment-variables.json
but anyway I fixed it, I set vidly_jwtPrivateKey = mySecret in fwindows powershell, than I called it const token = jwt.sign({ _id: user._id}, process.env.vidly_jwtPrivateKey );
now is working fine