简体   繁体   中英

angular2 routing not working when you deployed dist folder onto tomcat server

I generated dist folder in my project prj-routing-final with angular-cli with command ng-build --prod --aot and deployed on to tomcat server. i was able to navigate to all routes http://localhost:8081/dist/ and view them without reloading. Once if i navigate to http://localhost:8081/dist/recipes/0 and reload the page this error coming up

HTTP Status 404 – Not Found  
Type Status Report
Message /dist/recipes/0
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.14

I am not getting any errors if i serve with ng serve . i was able navigate to all routes, reload the pages, move back and forth.

I also tried serving dist with Http-server available in https://www.npmjs.com/package/http-server getting same kind of error after reloading No webpage was found for the web address: http://localhost:8080/recipes/0 GitHub repo of my project

Please kindly help me.

您将需要配置您的Web服务器,以将所有未知(404)请求重定向到index.html,这将允许Angular应用程序随后将您的用户路由到所需的路由/视图。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM