I am having an issue with a GO application that serves an Angular application when navigating to the http server. The browser comes back with a console error stating net::ERR_CONTENT_LENGTH_MISMATCH
The angular application is stored in a folder called dist.
Here is the code for serving the application
//create new gorilla mux router
r := mux.NewRouter()
// Handle all preflight request
r.Methods("OPTIONS").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// fmt.Printf("OPTIONS")
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, Access-Control-Request-Headers, Access-Control-Request-Method, Connection, Host, Origin, User-Agent, Referer, Cache-Control, X-header")
w.WriteHeader(http.StatusNoContent)
return
})
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}
r.Handle("/socket.io/", server)
r.Handle("/login", http.StripPrefix("/login", http.FileServer(http.Dir(dir+"/client/"))))
r.Handle("/dashboard", http.StripPrefix("/dashboard", http.FileServer(http.Dir(dir+"/client/"))))!
r.PathPrefix("/").Handler(http.FileServer(http.Dir(dir + "/client/")))
srv := &http.Server{
Handler: r,
Addr: "0.0.0.0:2000",
WriteTimeout: 15 * time.Second,
ReadTimeout: 15 * time.Second,
}
log.Fatal(srv.ListenAndServe())
Here is the error I am receiving.