【问题标题】:App works in development but not when deployed to heroku应用程序在开发中有效,但在部署到 heroku 时无效
【发布时间】:2020-10-07 21:25:04
【问题描述】:

我正在尝试将我的应用程序部署到 heroku。它毫无问题地推动,但是当我打开应用程序时它说。

应用程序错误 应用程序发生错误,无法提供您的页面。如果您是应用程序所有者,请查看您的日志以获取详细信息。您可以从 Heroku CLI 使用以下命令执行此操作 heroku 日志 --tail

我的日志给了我以下错误

2020-06-17T22:33:21.630742+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-dawn-11704.herokuapp .com request_id=23bad058-65f3-4ee2-bfdb-be4d560fb0f6 fwd="27.4.196.168" dyno= connect= service= status=503 bytes= protocol=https 2020-06-17T22:33:23.760317+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vast-dawn-11704.herokuapp .com request_id=56da289d-a7b5-44b0-b53e-059b3eb260e8 fwd="27.4.196.168" dyno= connect= service= status=503 bytes= protocol=https 2020-06-17T22:33:27.668207+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-dawn-11704.herokuapp.com request_id =7042d1ab-8d02-418e-8648-57f24b749dd0 fwd="27.4.196.168" 测功机=连接=服务=状态=503字节=协议=https 2020-06-17T22:33:28.338705+00:00 heroku[路由器]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vast-dawn-11704.herokuapp .com request_id=d585ff4f-42ee-434d-8943-8b8a7474f9dd fwd="27.4.196.168" dyno= connect= service= status=503 bytes= protocol=https 2020-06-17T22:36:03.372884+00:00 heroku[路由器]: at=error code=H10 desc="App crashed" method=GET path="/" host=vast-dawn-11704.herokuapp.com request_id =21d34f62-f174-4b49-a08f-6fda33e64c31 fwd="27.4.196.168" dyno=连接=服务=状态=503字节=协议=https 2020-06-17T22:36:04.037609+00:00 heroku[路由器]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=vast-dawn-11704.herokuapp .com request_id=5b1e452a-a254-42c1-8988-6f831da8458e fwd="27.4.196.168" dyno= connect= service= status=503 bytes= protocol=https

我的 server.js 代码如下所示

const express = require('express')
const cors = require('cors')
const connectDb = require('./config/db')

const app = express()

// Connect to database
connectDb()

// Initilize middleware
app.use(cors())
app.use(express.json())

// Define routes
app.use('/api/models', require('./routes/api/model'))
app.use('/api/modelParameters', require('./routes/api/modelParameters'))
app.use('/api/containers', require('./routes/api/container'))

const PORT = process.env.PORT || 5000

app.listen(PORT, console.log(`Listening on port ${PORT}`))

【问题讨论】:

  • 您是否在 heroku 上同时托管前端和后端?如果是,您的反应代码在 public/ 或 client/ 内?
  • 与@lucasmrl 的问题相同,您需要通过https 而不是http 提供所有服务。你实现了吗?
  • 嘿,我的反应是在客户端文件夹中,而 server.js 在根文件夹中。
  • 您好,我提出了这个问题,我想知道您是否可以在我指定所有内容的地方看到我的问题,请stackoverflow.com/questions/62626009/…

标签: javascript node.js reactjs mongodb heroku


【解决方案1】:

您可以检查问题原因(错误代码H10)和here列出的解决方案。也许其中一种解决方案会对您有所帮助

【讨论】:

    猜你喜欢
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多