I am using react-router-dom. Can I update path dynamically in react?

I am trying to update the path dynamically with api call. in router path. when I click the nav menu , first time it loads perfectly. but if I refresh it throws 404 error?

    <Routes>
      <Route path={`${item.path}`} element={<Platform />} />
      <Route path={`${item2.path}`} element={<Licensing />} />
    </Routes>
  </Router>

IS there any way to fix this?