I'm using a library that requires a secret string. I've set my node variable like so:
export JWT_SECRET=e177920e88165bd0090b1c6b544cf7
However, when I try to use it in my app, like so:
const jwt = require('jsonwebtoken');
function userToken(user) {
return jwt.sign({
user: user.id,
}, process.env.JWT_SECRET);
}
it hits an error that says the secret must be a string or buffer. I thought node variables are strings, so not sure what the issue is. Thanks.
process.env['VARIABLE'] = 'value';as you in this code vlaue should be define as string