Currently I am serving my react app using the following setup
func main() {
http.Handle("/", http.FileServer(http.Dir("./build/")))
http.HandleFunc("/my_api", handler)
http.ListenAndServe(":8090", nil)
}
and frontend
function App() {
return (
<Router>
<div>
<nav>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/my_frontend_path">MyPath</Link>
</li>
</ul>
</nav>
<Switch>
<Route path="/my_frontend_path">
<MyPath />
</Route>
<Route path="/">
<Home />
</Route>
</Switch>
</div>
</Router>
);
}
But when I directly access http://localhost:8090/my_frontend_path from the browser golang returns 404 page not found, is there a way to delegate any path not supported in main to default to frontend react router?