My solution was to return the index.html when 404 happens. It applicable to any SPA apps, not just Angular. I am using Vuejs for example.
P.S. The solution of the accepted answer didn't work for me. I mean it simply redirects to the index.hml, while I want the page to stay with the same url. For example hitting the url mysite/user/123 should show me the user details instead of redirecting to the index.html (home) page.