Здесь z моих двух файлов в папке config: default. json
{
"jwtPrivateKey": ""
}
Здесь z my custom-environment-varaibles.json
{
"jwtPrivateKey": "startup_jwtPrivateKey"
}
И я доступ к свойству из этого файла 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)
})
Я попытался вручную установить для переменной "startup_jwtPrivateKey" какое-то значение (т. е. не используя команду). И затем я попытался установить переменную "startup_jwtPrivateKey" в какое-то значение, используя эту команду set startup_jwtPrivateKey = mySecret . Но все равно я получаю эту ошибку
throw new Error('Configuration property "' + property + '" is not defined');
^
Error: Configuration property "jwtPrivatekey" is not defined
Здесь z my app. js file
if (!config.get('jwtPrivatekey')) {
console.error('Fatal error: config settings is not defined.')
process.exit(1);
}