You need to configure a fallback route on your server to serve index.html file when a route is not matched.This works:
location / { try_files $uri $uri/ /index.html?$query_string;}