I can't deploy an Angular app to heroku

2019-08-16 02:16发布

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:

enter image description here

and th Heroku logs is : enter image description here

when testing the deploy address, we get this result:

enter image description here

Your help is highly appreciated

1条回答
戒情不戒烟
2楼-- · 2019-08-16 02:42

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'));
});

Solution 2

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

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

It will deploy your application.

查看更多
登录 后发表回答