I have defined all my routes in App.js
file, given below
<BrowserRouter>
<Routes>
{user && <Route path="/dashboard" element={<Dashboard />} />}
<Route path='/' element={<SignUp />} />
<Route path='/signin' element={<Signin />} />
<Route path='/dashboard' element={<Navigate replace to="/signin" />} />
</Routes>
</BrowserRouter>
The first component is only rendered if there is a user
object defined. It defines the path /dashboard
and renders the Dashboard
component.
The second <Route>
component defines the path /
and renders the SignUp
component.
The third <Route>
component defines the path /signin
and renders the Signin
component.
The fourth <Route>
component also defines the path /dashboard
, but in this case, it uses the Navigate
component to redirect the user to the /signin
path. The replace attribute is used to replace the current route in the history stack, and the to attribute is used to define the path to redirect to.
In development it was working fine with all the routing but when deployed to Azure Static Web Apps it is showing 404 page not found. I have attached the image below which is for the URL https://agreeable-coast-05611e900.2.azurestaticapps.net/dashboard
I have hosted all the projects in GitHub feel free to check it out.