当我尝试启动应用程序时,在heroku中“无法确定Firebase数据库URL”错误是什么意思?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了当我尝试启动应用程序时,在heroku中“无法确定Firebase数据库URL”错误是什么意思?相关的知识,希望对你有一定的参考价值。

我刚刚完成了我的第一个反应应用程序,在这个应用程序中,有一个由Algolia服务生成的搜索栏。因此,我需要创建一个应用程序来记录我的数据库中的每个更改(我使用Firebase)。所以我按照Algolia提出的this tutorial创建了这个应用程序。在本地,当我运行我的应用程序时,一切正常。但是我需要在Heroku上部署这个应用程序,在完成上传到Heroku之后,我使用命令行“heroku open”但是我有一个错误。所以我在我的控制台中启动命令行“heroku logs --tail”,我有以下分析:

2019-01-19T22:39:11.633651+00:00 app[api]: Release v2 created by user camille.demarle@gmail.com
2019-01-19T22:39:11.482216+00:00 app[api]: Release v1 created by user camille.demarle@gmail.com
2019-01-19T22:39:11.482216+00:00 app[api]: Initial release by user camille.demarle@gmail.com
2019-01-19T22:39:51.000000+00:00 app[api]: Build started by user camille.demarle@gmail.com
2019-01-19T22:40:14.757634+00:00 app[api]: Deploy 8ebe9ea0 by user camille.demarle@gmail.com
2019-01-19T22:40:14.773417+00:00 app[api]: Scaled to web@1:Free by user camille.demarle@gmail.com
2019-01-19T22:40:18.000000+00:00 app[api]: Build succeeded
2019-01-19T22:40:30.451972+00:00 heroku[web.1]: State changed from starting to crashed
2019-01-19T22:40:30.462980+00:00 heroku[web.1]: State changed from crashed to starting
2019-01-19T22:40:30.428680+00:00 heroku[web.1]: Process exited with status 1
2019-01-19T22:40:30.295717+00:00 app[web.1]: [2019-01-19T22:40:30.291Z]  @firebase/database: FIREBASE FATAL ERROR: Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.initializeApp().
2019-01-19T22:40:30.302310+00:00 app[web.1]: /app/node_modules/@firebase/database/dist/index.node.cjs.js:335
2019-01-19T22:40:30.302314+00:00 app[web.1]: throw new Error(message);
2019-01-19T22:40:30.302316+00:00 app[web.1]: ^
2019-01-19T22:40:30.302317+00:00 app[web.1]: 
2019-01-19T22:40:30.302331+00:00 app[web.1]: Error: FIREBASE FATAL ERROR: Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.initializeApp().
2019-01-19T22:40:30.302340+00:00 app[web.1]: at fatal (/app/node_modules/@firebase/database/dist/index.node.cjs.js:335:11)
2019-01-19T22:40:30.302347+00:00 app[web.1]: at RepoManager.databaseFromApp (/app/node_modules/@firebase/database/dist/index.node.cjs.js:14987:13)
2019-01-19T22:40:30.302353+00:00 app[web.1]: at Object.instance.INTERNAL.registerService.Reference [as database] (/app/node_modules/@firebase/database/dist/index.node.cjs.js:15526:130)
2019-01-19T22:40:30.302355+00:00 app[web.1]: at FirebaseAppImpl._getService (/app/node_modules/@firebase/app/dist/index.node.cjs.js:138:66)
2019-01-19T22:40:30.302364+00:00 app[web.1]: at FirebaseAppImpl.(anonymous function) [as database] (/app/node_modules/@firebase/app/dist/index.node.cjs.js:327:31)
2019-01-19T22:40:30.302366+00:00 app[web.1]: at Object.serviceNamespace [as database] (/app/node_modules/@firebase/app/dist/index.node.cjs.js:312:32)
2019-01-19T22:40:30.302368+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:12:27)
2019-01-19T22:40:30.302370+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:702:30)
2019-01-19T22:40:30.302376+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
2019-01-19T22:40:30.302378+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:612:32)
2019-01-19T22:40:35.847284+00:00 heroku[web.1]: State changed from starting to crashed
2019-01-19T22:41:48.668846+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-01-19T22:41:45.297979+00:00 app[api]: Release v4 created by user camille.demarle@gmail.com
2019-01-19T22:41:45.297979+00:00 app[api]: Set ALGOLIA_APP_ID config vars by user camille.demarle@gmail.com
2019-01-19T22:42:15.784624+00:00 app[api]: Set ALGOLIA_API_KEY config vars by user camille.demarle@gmail.com
2019-01-19T22:42:21.343612+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-01-19T22:42:24.278823+00:00 heroku[web.1]: Process exited with status 1
2019-01-19T22:42:24.203298+00:00 app[web.1]: [2019-01-19T22:42:24.201Z]  @firebase/database: FIREBASE FATAL ERROR: Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.initializeApp().
2019-01-19T22:42:24.207461+00:00 app[web.1]: /app/node_modules/@firebase/database/dist/index.node.cjs.js:335
2019-01-19T22:42:24.207464+00:00 app[web.1]: throw new Error(message);
2019-01-19T22:42:24.207466+00:00 app[web.1]: ^
2019-01-19T22:42:24.207467+00:00 app[web.1]: 
2019-01-19T22:42:24.207478+00:00 app[web.1]: Error: FIREBASE FATAL ERROR: Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.initializeApp().
2019-01-19T22:42:24.207480+00:00 app[web.1]: at fatal (/app/node_modules/@firebase/database/dist/index.node.cjs.js:335:11)
2019-01-19T22:42:24.207482+00:00 app[web.1]: at RepoManager.databaseFromApp (/app/node_modules/@firebase/database/dist/index.node.cjs.js:14987:13)
2019-01-19T22:42:24.207484+00:00 app[web.1]: at Object.instance.INTERNAL.registerService.Reference [as database] (/app/node_modules/@firebase/database/dist/index.node.cjs.js:15526:130)
2019-01-19T22:42:24.207485+00:00 app[web.1]: at FirebaseAppImpl._getService (/app/node_modules/@firebase/app/dist/index.node.cjs.js:138:66)
2019-01-19T22:42:24.207487+00:00 app[web.1]: at FirebaseAppImpl.(anonymous function) [as database] (/app/node_modules/@firebase/app/dist/index.node.cjs.js:327:31)
2019-01-19T22:42:24.207489+00:00 app[web.1]: at Object.serviceNamespace [as database] (/app/node_modules/@firebase/app/dist/index.node.cjs.js:312:32)
2019-01-19T22:42:24.207490+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:12:27)
2019-01-19T22:42:24.207492+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:702:30)
2019-01-19T22:42:24.207494+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
2019-01-19T22:42:24.207495+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:612:32)
2019-01-19T22:42:46.165385+00:00 heroku[web.1]: State changed from crashed to starting
2019-01-19T22:42:45.890812+00:00 app[api]: Set ALGOLIA_INDEX_NAME config vars by user camille.demarle@gmail.com
2019-01-19T22:42:57.475941+00:00 heroku[web.1]: State changed from starting to crashed
2019-01-19T22:42:57.460531+00:00 heroku[web.1]: Process exited with status 1
2019-01-19T22:42:57.358726+00:00 app[web.1]: [2019-01-19T22:42:57.356Z]  @firebase/database: FIREBASE FATAL ERROR: Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.initializeApp().
2019-01-19T22:42:57.365146+00:00 app[web.1]: /app/node_modules/@firebase/database/dist/index.node.cjs.js:335
2019-01-19T22:42:57.365149+00:00 app[web.1]: throw new Error(message);
2019-01-19T22:42:57.365151+00:00 app[web.1]: ^
2019-01-19T22:42:57.365153+00:00 app[web.1]: 
2019-01-19T22:42:57.365164+00:00 app[web.1]: Error: FIREBASE FATAL ERROR: Can't determine Firebase Database URL.  Be sure to include databaseURL option when calling firebase.initializeApp().
2019-01-19T22:42:57.365166+00:00 app[web.1]: at fatal (/app/node_modules/@firebase/database/dist/index.node.cjs.js:335:11)
2019-01-19T22:42:57.365168+00:00 app[web.1]: at RepoManager.databaseFromApp (/app/node_modules/@firebase/database/dist/index.node.cjs.js:14987:13)
2019-01-19T22:42:57.365170+00:00 app[web.1]: at Object.instance.INTERNAL.registerService.Reference [as database] (/app/node_modules/@firebase/database/dist/index.node.cjs.js:15526:130)
2019-01-19T22:42:57.365171+00:00 app[web.1]: at FirebaseAppImpl._getService (/app/node_modules/@firebase/app/dist/index.node.cjs.js:138:66)
2019-01-19T22:42:57.365173+00:00 app[web.1]: at FirebaseAppImpl.(anonymous function) [as database] (/app/node_modules/@firebase/app/dist/index.node.cjs.js:327:31)
2019-01-19T22:42:57.365175+00:00 app[web.1]: at Object.serviceNamespace [as database] (/app/node_modules/@firebase/app/dist/index.node.cjs.js:312:32)
2019-01-19T22:42:57.365177+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:12:27)
2019-01-19T22:42:57.365179+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:702:30)
2019-01-19T22:42:57.365181+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
2019-01-19T22:42:57.365182+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:612:32)
2019-01-19T22:44:19.417434+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-01-19T22:44:19.417597+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-01-19T22:44:19.977203+00:00 heroku[web.1]: State changed from starting to crashed
2019-01-19T22:44:19.958621+00:00 heroku[web.1]: Process exited with status 137
2019-01-19T22:44:22.174368+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=immense-tundra-17222.herokuapp.com request_id=03b6ee82-8267-4695-8172-d382d14c917f fwd="176.161.115.132" dyno= connect= service= status=503 bytes= protocol=https
2019-01-19T22:54:22.270007+00:00 heroku[web.1]: State changed from crashed to starting
2019-01-19T22:54:26.834608+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-01-19T22:55:14.361517+00:00 heroku[web.1]: Process running mem=652M(127.4%)
2019-01-19T22:55:14.361517+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2019-01-19T22:55:27.356583+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-01-19T22:55:27.356583+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-01-19T22:55:28.057069+00:00 heroku[web.1]: State changed from starting to crashed
2019-01-19T22:55:28.034934+00:00 heroku[web.1]: Process exited with status 137

似乎这来自我与firebase的连接失败了,虽然我已经在我的.env文件中指定了路径,并且通过指定变量直接在Heroku中指定了路径(有疑问......)

这是我第一次尝试在Heroku上传应用程序。不知道能帮到我吗?

答案

它可以是任何东西,但最有可能的原因如下:

您在本地环境中使用的process.ENV变量在Heroku中不起作用。

在Heroku中,您必须设置所有process.ENV变量,如下所示:

heroku config:set FIREBASE_DATABASE_URL='https://abcd.firebaseio.com'

如果您有更多process.ENV变量,则可以在结尾处设置所有添加空间:

heroku config:set FIREBASE_DATABASE_URL='https://abcd.firebaseio.com'  FIREBASE_API_KEY: '1234'  FIREBASE_AUTH_DOMAIN: 'abc'

或者您可以在Heroku Dashboard中执行此操作:

看看this Heroku web-page两者。

以上是关于当我尝试启动应用程序时,在heroku中“无法确定Firebase数据库URL”错误是什么意思?的主要内容,如果未能解决你的问题,请参考以下文章

Heroku:每次测功机重新启动时都会丢失 Django 数据库文件

Gradle 应用程序无法启动

windows中heroku达到的最大setlocal递归级别

无法在 Heroku 教程中使用 Python 启动工头

尝试迁移数据库时,Django 应用程序在 Heroku 上崩溃

节点js的Heroku部署