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

时间:2019-01-19 23:06:58

标签: firebase heroku algolia

我刚完成我的第一个react应用程序,并且在此应用程序中,有一个由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中上传应用。不知道可以帮我吗?

1 个答案:

答案 0 :(得分:0)

可以是任何东西,但很可能是以下原因:

您在本地环境中使用的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仪表板中完成它:

同时查看this Heroku web-page