Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js React应用程序已成功部署到heroku,但状态未更新_Node.js_Reactjs_Heroku - Fatal编程技术网

Node.js React应用程序已成功部署到heroku,但状态未更新

Node.js React应用程序已成功部署到heroku,但状态未更新,node.js,reactjs,heroku,Node.js,Reactjs,Heroku,我有一个react应用程序,它使用节点后端与使用Heroku部署的CosmicJS约会调度器通信。一切正常,但我面临一个重大问题: 约会计划程序仍在跟踪localhost的更改,即我已添加代码以阻止已填充的插槽和日期,但部署的版本不跟踪这些更改,只有在我重新启动localhost并填充所述插槽后,部署的版本才会显示这些更改。我已经搜索了硬编码的localhost,但是还有其他的生产方法。日志中没有相关错误 期望的行为:在部署的应用程序上所做的更改应该反映在部署的版本上,而不仅仅反映在本地主机上

我有一个react应用程序,它使用节点后端与使用Heroku部署的CosmicJS约会调度器通信。一切正常,但我面临一个重大问题:

约会计划程序仍在跟踪localhost的更改,即我已添加代码以阻止已填充的插槽和日期,但部署的版本不跟踪这些更改,只有在我重新启动localhost并填充所述插槽后,部署的版本才会显示这些更改。我已经搜索了硬编码的localhost,但是还有其他的生产方法。日志中没有相关错误

期望的行为:在部署的应用程序上所做的更改应该反映在部署的版本上,而不仅仅反映在本地主机上

我已经添加了heroku的日志,我可以看到主机不是localhost…我不知道还有什么可以尝试的

以下是my 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"
  },

事实证明,这与heroku无关,但我部署应用程序的方式……我最终使用了CosmicJS的heroku部署选项,解决了我的问题。

首先在本地运行您的项目,使用npm Run watch thne打开新的cmd并推送您的代码
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