我做了一个简单的项目,其中维护了我的AWS dynamoDB的数据,在第一阶段,我通过db提取了所有数据并列出了项目,当我在本地计算机上运行项目但将其部署在heroku在碰到我的节点api时崩溃,显示404错误,这里是完整的错误截图
我也测试了项目以在静态端口上运行项目,但是无法正常工作。 您可以检查项目https://funcardmaker.herokuapp.com/update
这是我的Nodejs代码https://gist.github.com/amit0shakya/41a91df6cccb45665fd16b869801922e
这是heroku服务器日志。 2019-07-30T07:59:17.593103 + 00:00 heroku [router]:at = info method = GET path =“ / getalldata” host = funcardmaker.herokuapp.com request_id = 97923dda-2645-48fd-a0c5-8cf8e69b2955 fwd = “ 139.167.184.88” dyno = web.1 connect = 0ms service = 5ms status = 404字节= 416协议= https
答案 0 :(得分:1)
之所以不能使用getalldata
API的原因是因为您正在部署自己的React应用程序,而不是部署用于为您的生产React应用程序提供服务的express
服务器。因此,您需要配置package.json
才能启动express
服务器到serve
生产反应应用程序。您只需更改start
中的package.json
脚本即可启动express
而不是react
。
{
"name": "cardmaker3",
"version": "0.1.0",
"private": true,
"dependencies": {
"aws-sdk": "^2.464.0",
"axios": "^0.19.0",
"body-parser": "^1.19.0",
"dotenv": "^8.0.0",
"ejs": "^2.6.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-redux": "^7.1.0",
"react-router-dom": "^5.0.1",
"react-scripts": "3.0.1",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start-react": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"start": "node bin/config"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}