ronenmiller
ronenmiller

Reputation: 1137

Angular2 - Nginx route 404 error on cloudfoundry

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

Upvotes: 2

Views: 4059

Answers (2)

checketts
checketts

Reputation: 14953

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

Upvotes: 2

Anatoly Kern
Anatoly Kern

Reputation: 621

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

Upvotes: 3

Related Questions