我无法将 Angular 应用程序部署到 heroku [英] I can't deploy an Angular app to heroku

查看:41
本文介绍了我无法将 Angular 应用程序部署到 heroku的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Heroku 上部署我的 angular 6 应用程序,构建项目并执行所有部署步骤后,我在 heroku 上得到了这个结果:

I am trying to deploy my angular 6 app on Heroku, After building the project and following all the steps of deploy, I get this result on heroku:

和 th Heroku 日志是:

and th Heroku logs is :

在测试部署地址时,我们得到这样的结果:

when testing the deploy address, we get this result:

非常感谢您的帮助

推荐答案

您必须在 server.js 中添加通配符 get 路由为:

You will have to add wildcard get route in server.js as:

app.use(express.static(__dirname + '/dist'));

app.get('/*', function(req, res) {
    res.sendFile(path.join(__dirname + '/dist/index.html'));
});

解决方案 2

在dist文件夹中添加一个index.php文件,在其中添加如下代码:

add one index.php file in dist folder add following code in it:

<?php header( 'Location: /index.html' ) ;  ?>

它将部署您的应用程序.

It will deploy your application.

这篇关于我无法将 Angular 应用程序部署到 heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆