'ngnix conf to refresh the create react app with nested routes

I am working on a react app that is built on top of create-react-app. My app uses client side routing withr react-router and has nested routing /abc/xyz/:id.

We are hosting the app on server with ngnix. When I have the below configuration for ngnix

location / { 
    root /usr/share/nginx/html; 
    index index.html index.htm; 
    try_files $uri /index.html?$args; 
  } 

The app is loaded fine and routing worked fine. But, page refresh didn't work and threw 404 errors.

When I changed the config to below, everything worked fine including page refresh on nested routes.

location / { 
    root /usr/share/nginx/html; 
    index index.html; 
    try_files $uri /index.html$is_args$args;
  }

I'm not clear on the difference between these two configurations. Can someone please help me clarify the difference and what made it work in the second ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source