I have local a react app, and using react-router-dom for routing.
The problem: For example, if I navigate to the graphs page, my adress bar is showing the url in the format: http://localhost:8085/#/graphs
How can i get rid of the "#"?
Below is my code, and the routings:
// App.jsx
<Routes>
<Route path="/" element={<Login onLogin={handleLogin} />} />
{isLoggedIn ? (
<Route path="/" element={<Root onLogout={handleLogout} />}>
<Route index element={<Home />} />
<Route path="user-registration" element={<Register />} />
<Route path="graphs" element={<Graphs/>} />
</Route>
) : null}
</Routes>
// index.js
ReactDOM.render(
<React.StrictMode>
<Provider store={store}>
<Router>
<Routes>
<Route path="/*" element={<App />} />
</Routes>
</Router>
</Provider>
</React.StrictMode>,
document.getElementById("app")
);
react-router-dom version: ^6.2.1 react version: ^17.0.2
I tried using Browser router, which takes care of the "#", but another problems comes. If im in graphs or any other component, and I refresh the page, I get the error: Cannot GET /dashboard.