This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
root /usr/share/nginx/html; | |
gzip on; | |
gzip_types text/css application/javascript application/json image/svg+xml; | |
gzip_comp_level 9; | |
etag on; | |
location / { | |
try_files $uri $uri/ /index.html; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
ErrorViewResolver redirectToFrontEndOn404() { | |
return ( request, status, model ) -> status == HttpStatus.NOT_FOUND | |
? new ModelAndView("forward:/index.html", Collections.<String, Object>emptyMap(), HttpStatus.OK) | |
: null; | |
} | |
This is necessary on page refresh to avoid showing 404 or error pages | |
This forward also maintains the client route path, so angular will route to the correct route on reload. |