I have an Angular application that is routed from a Spring Gateway. The root route works correctly but when you deep into nested routes it returns status not found. On Angular docs and this tutorial say that you must rewrite any not found route to /index.html but I not found any reference in Spring Cloud Gateway docs for how to do configure this.
application.yml
- id: teams-frontend
uri: lb://teams-frontend
predicates:
- Path=/teams,/teams/**
filters:
- StripPrefix=1
# - RewritePath=/.*, /index.html ## This breaks existing link resources such as the scripts linked on the index.html
How can angular app fallback to index.html when it is not found?
I developed a custom filter. If the request contains a header "Accept: text/html" then the request path is overwritten with /index.html
- id: teams-frontend
uri: lb://teams-frontend
predicates:
- Path=/teams,/teams/**
filters:
- StripPrefix=1
- SPA