[英]Heroku deployed app is not sending proper response while if I run heroku locally using heroku local web , I am getting proper response
我正在尝试将 node+express+mongo 部署到 heroku 中。
index.js
const PORT = process.env.PORT || 3200;
const CONNECTION_URL =
"mongodb+srv://aarthi:C<password>@cluster0.prt4u.mongodb.net/BookMyShow?retryWrites=true&w=majority";
mongoose
.connect(CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() =>
app.listen(PORT, () =>
console.log(
`Server Running on Port:https://immense-sands-26614.herokuapp.com/`
)
)
)
.catch((error) => console.log(`${error} did not connect`));
package.json
{
"name": "hackathon_server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.js"
},
"keywords": [
"example",
"heroku"
],
"author": "",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"mongodb": "^3.6.6",
"mongoose": "^5.12.3",
"nodemon": "^2.0.7",
"validator": "^13.5.2"
},"engines": {
"node": "14.15.1"
}
}
现在我正在尝试使用本地 heroku 使用 heroku 本地 web 运行节点
:47:13 pm web.1 | [nodemon] 2.0.7
4:47:13 pm web.1 | [nodemon] to restart at any time, enter `rs`
4:47:13 pm web.1 | [nodemon] watching path(s): *.*
4:47:13 pm web.1 | [nodemon] watching extensions: js,mjs,json
4:47:13 pm web.1 | [nodemon] starting `node index.js`
4:47:17 pm web.1 | (node:33016) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
4:47:17 pm web.1 | (Use `node --trace-deprecation ...` to show where the warning was created)
4:47:17 pm web.1 | Server Running on Port:https://immense-sands-26614.herokuapp.com/
同时击中 postman api req 得到正确响应
但是当我点击部署的 heroku 应用程序的请求时,出现错误Deployed Heroku 应用程序
我看到部署的 heroku 的控制台上正在运行什么,看起来不错
不确定是什么问题。 有人请帮忙解决这个问题
终于弄清楚了问题所在。
我通过不支持的 https:// 发送请求
将我的请求 url 更改为 http://... http://immense-sands-26614.herokuapp.com/api/movies
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.