Angular 2 Routing Does Not Work When Deployed to Http Server

前端 未结 18 1900
误落风尘
误落风尘 2020-12-07 22:42

I am going to develop a simple Angular 2 application. I have created a project with routing, using Angular CLI and added several components to the app using \'ng generate co

18条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 23:03

    Change your index.html

    
     to 
    
    

    Because we are using Tomcat we have mentioned this(.) for Routing is based on this(/) So same like http-server

    I mean running normally ng serve you have seen only http://localhost:4200/

    but run in server you have put your build into(dist) in webapps

    so its come like

    http://localhost:8080/dist/
    

    so you need to add

    i think this is the problem for you may be solved.

提交回复
热议问题