I can't deploy an Angular app to heroku

末鹿安然 提交于 2019-12-25 02:15:51

问题


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.



来源:https://stackoverflow.com/questions/51163784/i-cant-deploy-an-angular-app-to-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!