Nginx not found nested routes when i reload the page

Hi, just deployed my app:

  • Vite
  • React
  • React router

My app is client based and utilizes routes to show inner parts of an app myapp.dev/book/page/id
Its working fine on dev, but there is strange behavior on fly.io:

It is working fine, when i went to the root myapp.dev, then its automatically redirects to /book(this is by design of my app) and also it’s working fine when during app usage i go to /pages but if i reload an app being in nested route, i get nginx error “not found”. So to “reset an app” i should manually type myapp.dev.

Anyone know why is this happening and what settings i should tune?

as far as i understand this is due to client routing. I need to somehow specify fallback for nginx. Is there simple way of setting this up maybe in fly.toml? nginx must redirect to root

Fixed by adding

location / {
        try_files $uri /index.html;
    }

in nginx config. So i created nginx config in my project and set up copying in dockerfile