I can't deploy an Angular app to heroku

2019-08-16 02:15发布

问题:

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:

and th Heroku logs is :

when testing the deploy address, we get this result:

Your help is highly appreciated

回答1:

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.