(Casey) #1

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")

dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {

r.Handle("/", 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:         "",
	WriteTimeout: 15 * time.Second,
	ReadTimeout:  15 * time.Second,


Here is the error I am receiving.

(Jakob Borg) #2

It also took a minute for those requests to complete (error out). I would look at the usual suspects on Windows - antivirus, and then possibly a proxy if you use one.

(Casey) #3

I am able to access it locally with no problem. It appears to happen when trying to access the webserver over a vpn connection. That appears to be the issue? Unless there is another issue with

The requests that error out appear to be random. Sometimes only one will error out (fail) or many will.

(Jakob Borg) #4

I’m afraid it sounds like a problem with your environment somehow, rather than with the Go server side.