Here z my two files under folder config:default.json
{"jwtPrivateKey": ""}
Here z my custom-environment-varaibles.json
{"jwtPrivateKey": "startup_jwtPrivateKey"}
And i am accessing the property from this file users.js
router.post('/signin', async (req, res) => { const { error } = validateLogin(req.body); if (error) return res.status(400).send(error.details[0].message); let user = await User.findOne({ email: req.body.email }); if (!user) return res.status(400).send('No user found with the given credentials.'); const matchPassword = await bcrypt.compare(req.body.password, user.password) if (!matchPassword) return res.status(400).send('Invalid password') const token = jwt.sign({ _id: user._id}, config.get('jwtPrivateKey')) res.send(token)})
I have tried to manually set the variable "startup_jwtPrivateKey" to some value (i.e. not using the command) .And then i tried to set the variable "startup_jwtPrivateKey" to some value using this command set startup_jwtPrivateKey=mySecret . But still i am getting this error
throw new Error('Configuration property "'+ property +'" is not defined'); ^Error: Configuration property "jwtPrivatekey" is not defined
Here z my app.js file
if (!config.get('jwtPrivatekey')) { console.error('Fatal error: config settings is not defined.') process.exit(1);}