I am navigating the user to chat page when the user login but when the I click on back arrow[provided in image] then it won't let me to move back cause when I click on that it sends me to http://localhost:3000/login and again it will redirect me to http://localhost:3000/chat [because I am sending user to chat page if the token is available in localstorage] so how can i make that when the user click on back arrow it will directly navigate user to http://localhost:3000/
Routes
const { token } = useSelector((state) => state.auth);
return (
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="about" element={<About />} />
<Route path="contact" element={<Contact />} />
<Route
path="login"
element={!token ? <Login /> : <Navigate to="/chat" />}
/>
<Route path="register" element={<Register />} />
</Route>
<Route path="/chat">
<Route
index
element={token ? <ChatPage /> : <Navigate to="/login" />}
/>
</Route>
</Routes>
);