How to use PathLocationStrategy on localhost?

六月ゝ 毕业季﹏ 提交于 2021-02-11 13:21:14

问题


I'm working on an Angular 4 web app and I need to use PathLocationStrategy (not HashLocationStrategy).

The only problem with PathLocationStrategy is that when I refresh a page, I instantly get a blank page with 404 errors in the console... Which is normal with PathLocationStrategy.

Once on a server, I can fix that by redirecting the routes to point on index.html. But how to fix this issue on localhost when I launch my app with ng serve?

It would be ideal since I'm working in "livereload", because when I update a file, I get a blank page and I have to restart from the base path.

So is it possible to use PathLocationStrategy when working in localhost?


回答1:


ng serve take care of both Strategy. Locally I am using PathLocationStrategy



来源:https://stackoverflow.com/questions/52738574/how-to-use-pathlocationstrategy-on-localhost

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