且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我无法将 Angular 应用程序部署到 heroku

更新时间:2022-06-24 03:14:21

您必须在 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.