[go-nuts] Re: CORS error when using Gorilla Mux

2017-06-04 Thread Oren
update: to only allow ajax requests from my domains I modify the code: w.Header().Set("Access-Control-Allow-Origin", "https://foo.my-domain.com";) w.Header().Set("Access-Control-Allow-Origin", "https://bar.my-domain.com";) w.Header().Set("Access-Control-Allow-Origin", "http://localhost:8080) O

[go-nuts] Re: CORS error when using Gorilla Mux

2017-06-04 Thread Oren
I solved with the following: package main import ( "log" "net/http" "github.com/gorilla/mux" ) func corsMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { log.Println("Executing middleware", r.Method) if r.Method == "OP