node.js - 将 vue 应用程序部署到 heroku 时出错
问题描述
我有一个使用 vue cli 设置的 vuejs 应用程序,我正在尝试将我的应用程序部署到 heroku。
这是我的服务器:
const express = require('express');
const port = process.env.PORT || 8080;
const app = express();
app.use(express.static(__dirname + "/dist/"));
app.get(/.*/ , function(req,res) {
res.sendfile(__dirname + "/dist/index.html");
});
app.listen(port);
console.log("Server started...");
- 我从 gitignore 中删除 dist,
- 我在 package.json 中添加了一个像 "start": "node server.js" 这样的起点
这是我在控制台上看到的:
加载资源失败:服务器响应状态为 503(服务不可用)/favicon.ico:1
这是heroku日志:
2019-12-13T08:55:49.464914+00:00 heroku[路由器]: at=error code=H10 desc="App crashed" method=GET path="/" host=followgoals.herokuapp.com request_id=09df33ae-96ab -415a-929b-530fb943318d fwd="37.130.123.179" dyno= connect= service= status=503 bytes= protocol=https 2019-12-13T08:55:49.828341+00:00 heroku[router]: at=error code= H10 desc="App crashed" method=GET path="/favicon.ico" host=followgoals.herokuapp.com request_id=21de7307-502e-4104-a648-8e6b0832a3fe fwd="37.130.123.179" dyno= connect= service= status =503字节=协议=https
那么我能做些什么来解决问题呢?
解决方案
我遇到了同样的问题,在 heroku 上处理本地 503 错误,我通过转到我的数据库云服务(mongodb atlas)来修复它,并将集群上的白名单设置从“家”更改为“任何地方”。
推荐阅读
- sql - 保留 Range 数据类型的下限/上限
- python - 如何使用 Python 从 HTML 段落中提取描述
- android - 使用 Material Motion Fade 的 DialogFragment 动画
- mfc - 我想在 MFC 的树控件中防止双击事件?
- c# - 如何更新列表中的多个项目
- css - 为什么截断的文本在我的弹性框中不起作用?
- java - 这个循环的时间复杂度应该是多少
- jquery - 尽管已添加到 react-app,但 Jquery 仍无法运行
- python - python pymssql 错误:18456,b'DB-Lib 错误消息 20010,严重性 8:\n无法分配足够的内存
- image - React Native 中的图像滚动缩放