I'm trying to set up a route to serve my reactjs application.
I have my index.html and bundle.js in the public folder
/public/index.html
/public/bundle.js
I'm using go as my backend API, and also to serve my reactjs app.
I created a subroute for my app like:
r := mux.NewRouter()
app := r.Host("app.example.com").Subrouter()
So any request with app as the subdomain will be for my Reactjs app.
So now I have to serve every request regardless of the URL to my reactjs app.
Is path prefix what I need here?
I tried this:
app.PathPrefix("/").Handler(serveReact)
func serveReact(w http.ResponseWriter, r *http.Request) {
}
But I get this error:
cannot use serveReact (type func() http.Handler) as type http.Handler in argument to app.PathPrefix("/").Handler: func() http.Handler does not implement http.Handler (missing ServeHTTP method)