![](/img/trans.png)
[英]How do I solve this “Cannot read property 'appendChild' of null” error?
[英]How do I solve Configuration property "jwt" and "DB" is not defined error
我正在嘗試將我的 web 應用程序(MERN 堆棧)推送到 Heroku,但我一直收到此錯誤
我在 index.js 中嘗試過的
if (!config.get("jwtPrivateKey")) {
throw new Error('FATAL ERROR!!: jwtPrivateKey is not defined')
}
console.log(config.get("DB"))
console.log(config.get("jwtPrivateKey"))
這是我記錄它們時的值
在配置文件夾中有兩個文件 default.json 和 custom-environment-variables.json default.json
{
"jwtPrivateKey" : "",
"requiresAuth": false,
"DB":"mongodb+srv://****/test"
}
自定義環境變量.json
{
"jwtPrivateKey" : "RhinoJohn_jwtPrivateKey",
"DB": "Rhinojohn_DB"
}
當我運行 heroku config 時,變量在這里輸入圖像描述
我檢查了這個問題,但沒有一個答案能解決我的問題。 如何解決未定義配置屬性“jwtPrivateKey”? 我別無選擇
您也可以使用環境變量而不是文件,因為 heroku 很好地支持它們並將它們用作
process.env.VARIABLE_NAME
因為你在 .env 文件中使用 react 你需要將它們存儲為
#.env file
REACT_APP_SECRET_NAME=secretvalue
這意味着必須以REACT_APP_
如果您使用的是 git,請不要忘記將其添加到 gitignore 文件中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.