From 9b4a781f717352152dfb62f13f1f3493199132f1 Mon Sep 17 00:00:00 2001 From: Marcos Lilljedahl Date: Sun, 18 Feb 2018 23:06:24 -0300 Subject: [PATCH] Change CORS allowed headers to PWD --- handlers/bootstrap.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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")