简体   繁体   English

Heroku 部署的应用程序没有发送正确的响应,而如果我在本地运行 heroku 使用 heroku 本地 Z2567A5EC9705EB7AC2C984033 得到正确的响应

[英]Heroku deployed app is not sending proper response while if I run heroku locally using heroku local web , I am getting proper response

I am trying to deploy a node+express+mongo into heroku.我正在尝试将 node+express+mongo 部署到 heroku 中。

index.js 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 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"
  }
}

Now I am trying to run the node using local heroku using heroku local web现在我正在尝试使用本地 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/

while hitting the postman api req getting proper response同时击中 postman api req 得到正确响应

api req when running locally本地运行时的 api req

But when I hit request for the deployed heroku app, Getting error Deployed Heroku app但是当我点击部署的 heroku 应用程序的请求时,出现错误Deployed Heroku 应用程序

I saw what is running on console of deployed heroku, it seems fine我看到部署的 heroku 的控制台上正在运行什么,看起来不错

Console on web heroku web heroku 上的控制台

Not sure what the problem is.不确定是什么问题。 someone please help to solve this有人请帮忙解决这个问题

Finally figurred out the problem.终于弄清楚了问题所在。

I am sending request via https:// which is not supported我通过不支持的 https:// 发送请求

changed my request url to http://... http://immense-sands-26614.herokuapp.com/api/movies将我的请求 url 更改为 http://... http://immense-sands-26614.herokuapp.com/api/movies

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我在 heroku 中部署我的应用程序时,获取 html 时出错 - Error getting html when I deployed my app in heroku 我正在尝试使用 heroku 部署一个简单的 nodejs 应用程序,它已成功部署,但在打开 url 时出错? - I am trying to deploy a simple nodejs app using heroku and its is deployed successfully but giving error on opening the url? I've deployed a nodejs api to Heroku and a React app to my personal site and I'm getting cors errors but going to the api url directly gets response? - I've deployed a nodejs api to Heroku and a React app to my personal site and I'm getting cors errors but going to the api url directly gets response? 为什么在没有响应的情况下关闭连接Heroku部署的Node.js应用程序 - Why does the Connection close without a response Heroku deployed nodejs app Twitter端点请求在部署到Heroku的Node应用程序中获取HTML响应 - Twitter endpoint request gets HTML response in Node app deployed to Heroku 从heroku将Keystone应用程序克隆到本地存储库时,为什么会得到空的存储库? - Why am I getting an empty repo when cloning my keystone app to local repo from heroku? 部署到heroku时,出现以下错误日志 - While deploying to heroku , I am getting the following error log 我正在尝试将 MERN 应用程序部署到 heroku 但出现此错误 - I am trying to deploy MERN app to heroku but getting this error 为什么在 Heroku 上部署 nodejs 应用程序时出现此应用程序错误? - why am i getting this application error while deploying nodejs app on Heroku? 部署 mern 应用程序时出现 heroku 节点错误 - I'm getting heroku node errors while deploying the mern app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM