node.js - React 应用程序成功部署到heroku,但状态未更新
问题描述
我有一个使用 Node 后端与使用 Heroku 部署的 CosmicJS 预约调度程序进行通信的反应应用程序。一切都很好,但我面临一个主要问题:
约会调度程序仍在跟踪来自 localhost 的更改,即我添加了代码来阻止填充的插槽和日期,但是部署的版本没有跟踪这些更改,只有在我重新启动 localhost 并填充所述插槽后,部署的版本才会显示这些更改。我已经搜索了硬编码的本地主机,但有生产的替代方案。日志中没有相关错误。
期望的行为:对已部署应用程序所做的更改应反映在已部署的版本上,而不仅仅是在 localhost 中。
我已经从heroku添加了日志,我可以看到主机不是本地主机......我不知道还有什么可以尝试的。
这是我的 package.json 的一部分:
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"homepage": "/",
"engines": {
"node": "12.x",
"npm": "6.14.8"
},
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js",
"build": "webpack",
"heroku-postbuild": "npm install && npm run build"
},
2020-11-15T20:14:39.846723+00:00 app[web.1]: [0mPOST /api/appointments [32m200[0m 688.890 ms - 17[0m
2020-11-15T20:14:39.974220+00:00 app[web.1]: [0mGET / [36m304[0m 0.710 ms - -[0m
2020-11-15T20:14:39.973138+00:00 heroku[router]: at=info method=GET path="/" host=ancient-thicket-51544.herokuapp.com request_id=bb79006f-cadc-472d-b0d0-ea420d5a105a fwd="72.70.63.16" dyno=web.1 connect=1ms service=3ms status=304 bytes=269 protocol=https
2020-11-15T20:14:39.851778+00:00 heroku[router]: at=info method=POST path="/api/appointments" host=ancient-thicket-51544.herokuapp.com request_id=1a8f60db-7cc2-4399-a910-4b1eb7323662 fwd="72.70.63.16" dyno=web.1 connect=1ms service=693ms status=200 bytes=256 protocol=https
2020-11-15T20:14:40.125957+00:00 heroku[router]: at=info method=GET path="/bundle.js" host=ancient-thicket-51544.herokuapp.com request_id=4a994db7-1803-400d-af48-9fb2e5d3f9cf fwd="72.70.63.16" dyno=web.1 connect=1ms service=7ms status=304 bytes=272 protocol=https
2020-11-15T20:14:40.122394+00:00 app[web.1]: [0mGET /bundle.js [36m304[0m 0.541 ms - -[0m
2020-11-15T20:14:40.436762+00:00 heroku[router]: at=info method=GET path="/bundle.map.js" host=ancient-thicket-51544.herokuapp.com request_id=bd505bb0-6bac-45e9-8e50-24627ee1a7bc fwd="72.70.63.16" dyno=web.1 connect=1ms service=3ms status=304 bytes=272 protocol=https
2020-11-15T20:14:40.437734+00:00 app[web.1]: [0mGET /bundle.map.js [36m304[0m 0.543 ms - -[0m
2020-11-15T20:14:40.555878+00:00 app[web.1]: [0mGET /api/appointments [32m200[0m 10.989 ms - 877[0m
2020-11-15T20:14:40.555417+00:00 heroku[router]: at=info method=GET path="/api/appointments" host=ancient-thicket-51544.herokuapp.com request_id=f09f39cd-415b-45d3-a5b9-eb13ec8f69f1 fwd="72.70.63.16" dyno=web.1 connect=1ms service=13ms status=200 bytes=1118 protocol=https
2020-11-15T20:14:40.800303+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'metadata' of undefined
2020-11-15T20:14:40.800304+00:00 app[web.1]: at /app/server.js:92:34
2020-11-15T20:14:40.800305+00:00 app[web.1]: at /app/node_modules/cosmicjs/index.js:92:16
2020-11-15T20:14:40.800305+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-11-15T20:14:40.800395+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
2020-11-15T20:14:41.196652+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=ancient-thicket-51544.herokuapp.com request_id=f34e7212-2359-475a-9b9b-626c4dc3f393 fwd="72.70.63.16" dyno=web.1 connect=1ms service=3ms status=302 bytes=244 protocol=https
2020-11-15T20:14:41.196004+00:00 app[web.1]: [0mGET /favicon.ico [36m302[0m 0.731 ms - 23[0m
2020-11-15T20:14:41.225031+00:00 app[web.1]: [0mGET / [32m200[0m 0.725 ms - 530[0m
2020-11-15T20:14:41.225348+00:00 heroku[router]: at=info method=GET path="/" host=ancient-thicket-51544.herokuapp.com request_id=c9a3adef-8221-4f98-a85f-dd68cc4a553b fwd="72.70.63.16" dyno=web.1 connect=1ms service=3ms status=200 bytes=850 protocol=https
2020-11-15T20:14:55.007158+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/api/config" host=ancient-thicket-51544.herokuapp.com request_id=0921b397-a979-4373-9667-6472f19427ab fwd="72.70.63.16" dyno=web.1 connect=1ms service=30003ms status=503 bytes=0 protocol=https
2020-11-15T20:14:55.010286+00:00 app[web.1]: [0mGET /api/config [0m-[0m - ms - -[0m
2020-11-15T20:15:10.789420+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/api/config" host=ancient-thicket-51544.herokuapp.com request_id=506e106e-5dcf-454c-ada9-972644f2a1ed fwd="72.70.63.16" dyno=web.1 connect=2ms service=30000ms status=503 bytes=0 protocol=https
2020-11-15T20:15:10.794416+00:00 app[web.1]: [0mGET /api/config [0m-[0m - ms - -[0m
解决方案
事实证明,它与 heroku 无关,而是我部署应用程序的方式......我最终使用 CosmicJS 的部署选项到 heroku,这解决了我的问题。
推荐阅读
- r - 在 R 中使用 IF 语句
- tensorflow - 如何理解 TFRecords 格式的 tensorflow.data.Dataset() 中的 shuffle 方案
- java - Java DateTimeFormatter:仅在不为 0 时将毫秒打印到 3 个位置
- git - Git Aborting with "git pull origin master --allow-unrelated-histories"
- javascript - 需要时未读取二维码
- apache-spark - 如何在pyspark中使用带有两列的date_add?
- python - 在 Python 中异步播放声音
- javascript - 在单独的对象中使用 reduce 进行对象解构
- python - 如何使用 python 将文本打印到 .txt 文件中
- javascript - 我正在学习如何将 javascript 转换为 jquery,但无法通过全局变量正确转换