I'm trying to deploy an Angular 4 app with a Java backend on Google App Engine (standard). Everything works fine except when I try to reload the page. What happens is that a request to e.g. myapp.com/some/page should be redirected to myapp.com/index.html for the Angular app to respond.
As far as I can see, this would be possible if using the app.yaml configuration file which is used for all supported languages except Java (which uses appengine-web.xml and web.xml).
Can this be done with appengine-web.xml? In any other way?
Yes you have to use the HashLocationStrategy instead of the default PathLocationStrategy.
Angular's documentation: https://angular.io/guide/router#appendix-locationstrategy-and-browser-url-styles
Basically, you just have to tell the RouterModule to use HashLocationStrategy in your AppRoutingModule:
I hope it helps
If you want to keep the PathLocationStrategy which is the default "HTML5 pushState" style, you need to implement a redirect on the backend side. Basically you need to add a filter or servlet with "/*" as the URL pattern with the following behavior:
As a follow up to Gwendal Le Cren's answer, I did this and needed a few more things with the filter, so I'll put them below.