问题
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