I'm using React Browser Router, as an npm module (react-router-dom) with create-react-app. Routing works fine on local but not after deployment. When pressing a link I'm not taken to the desired location (for example /start). The page can not be found.
I looked at this tip but it still doesn't work.
I'm not using Heroku and I don't know if I should be.
Here are some code snippets from my react App.js:
import { BrowserRouter, Route, Switch } from "react-router-dom";
import Home from "./Components/Home.jsx";
import Billigast from "./Components/Billigast";
import NoMatch from "./Components/NoMatch";
import Start from "./Components/Start";
class App extends Component {
render() {
return (
<BrowserRouter>
<div>
<NavBar />
<Switch>
<Route path="/" component={Home} exact />
<Route path="/start" component={Start} />
<Route component={NoMatch} />
</Switch>
</div>
</BrowserRouter>
);
}
}
static.json:
{
"root": "/",
"clean_urls": false,
"routes": {
"/**": "index.html"
}
}
I've tried several "root":
locations. My index.html file is in root.
Here is one of the linked pages:
import React from "react";
import NavBar from "./NavBar";
import Form from "./Form";
const Start = () => {
return (
<div>
<Form />
</div>
);
};
export default Start;
Thank you for any help!