Angular2 - Nginx route 404 error on cloudfoundry

末鹿安然 提交于 2019-12-22 18:35:40

问题


I am using cloud foundry platform to deploy angular2 app using nginx based ststicfile buildpack.

Upon refreshing on a sub route /my-route I am getting 404. I want any path such as www.mysite.com/some-ng2-router-path to redirect back to www.mysite.com

I have seen several posts about this but I can't figure out how to edit the nginx.conf file on the server, and I do not want to use the hash bang approach.

What do I do?

Thanks


回答1:


Are you trying to map routes within your app? e.g. cf map-route angular-app mysite.com --hostname www --path some-ng2-router-path

More on https://docs.cloudfoundry.org/devguide/deploy-apps/routes-domains.html#map-route

It should work with http://docs.cloudfoundry.org/buildpacks/staticfile/index.html#pushstate




回答2:


No route mapping is needed. Create a file named Staticfile that is in your root. The contents of the Staticfile should be:

pushstate: enabled

The buildpack docs include other options you can enable for nginx: http://docs.cloudfoundry.org/buildpacks/staticfile/index.html#pushstate



来源:https://stackoverflow.com/questions/42465155/angular2-nginx-route-404-error-on-cloudfoundry

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