diff --git a/handlers/bootstrap.go b/handlers/bootstrap.go index f79dd0e..0705675 100644 --- a/handlers/bootstrap.go +++ b/handlers/bootstrap.go @@ -9,6 +9,7 @@ import ( "io/ioutil" "log" "net/http" + "strings" "time" "golang.org/x/crypto/acme/autocert" @@ -56,7 +57,12 @@ func Register(extend HandlerExtender) { r := mux.NewRouter() corsRouter := mux.NewRouter() - corsHandler := gh.CORS(gh.AllowCredentials(), gh.AllowedHeaders([]string{"x-requested-with", "content-type"}), gh.AllowedMethods([]string{"GET", "POST", "HEAD", "DELETE"}), gh.AllowedOrigins([]string{"http://training.play-with-docker.com", "http://play-with-moby.com", "http://ee-labs.play-with-docker.com", "http://ee-beta-labs.play-with-docker.com"})) + corsHandler := gh.CORS(gh.AllowCredentials(), gh.AllowedHeaders([]string{"x-requested-with", "content-type"}), gh.AllowedMethods([]string{"GET", "POST", "HEAD", "DELETE"}), gh.AllowedOriginValidator(func(origin string) bool { + if strings.HasSuffix(origin, "play-with-docker.com") { + return true + } + return false + })) // Specific routes r.HandleFunc("/ping", Ping).Methods("GET")