I create a jhipster app successfully, then login with admin/admin, click user-management, all works, the url changes to localhost:9000/user-management.
However, when
If you set useHash: false
and click on refresh, the request is sent to the server so you get this exact error you had: a client route being processed by server and not found. So you must adapt the server side using a servlet filter, see details in https://github.com/jhipster/generator-jhipster/issues/4794#issuecomment-304097246
Please note also that this approach does not easily work for gateways in microservices architecture.
Here is an example of such a filter that you can adapt and which forwards requests for client routes to '/' so that they get interpreted by the angular app in index.html:
public class AngularRouteFilter extends OncePerRequestFilter {
// add the values you want to redirect for
private static final Pattern PATTERN = Pattern.compile("^/((api|swagger-ui|management|swagger-resources)/|favicon\\.ico|v2/api-docs).*");
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain)
throws ServletException, IOException {
if (isServerRoute(request)) {
filterChain.doFilter(request, response);
} else {
RequestDispatcher rd = request.getRequestDispatcher("/");
rd.forward(request, response);
}
}
protected static boolean isServerRoute(HttpServletRequest request) {
if (request.getMethod().equals("GET")) {
String uri = request.getRequestURI();
return PATTERN.matcher(uri).matches();
}
return true;
}
}