'Cannot find route when going directly by URL react-router-dom
I have some routes
<Route path="/bany" exact>
<Bany />
</Route>,
<Route path="/sklep" exact>
<Sklep />
</Route>,
<Route path="/cooferujemy" exact>
<CoOferujemy />
</Route>,
<Route path="/404" exact>
<NotFound />
</Route>,
<Redirect to="/404" />,
Everything works just fine, when I'm just going to routes by clicking buttons, but when I want to go to route directly by URL I get the 404 route. There are my package.json dependencies:
"dependencies": {
"aos": "^2.3.4",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react-router-dom": "^5.3.0"
},
"devDependencies": {
"@honkhonk/vite-plugin-svgr": "^1.1.0",
"@vitejs/plugin-react-refresh": "^1.3.1",
"autoprefixer": "^10.4.2",
"postcss": "^8.4.8",
"tailwindcss": "^3.0.23",
"vite": "^2.4.4"
}
How to fix it?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
