Change CORS allowed headers to PWD

This commit is contained in:
Marcos Lilljedahl
2018-02-18 23:06:24 -03:00
parent 81261a0afc
commit 9b4a781f71

View File

@@ -9,6 +9,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
"strings"
"time" "time"
"golang.org/x/crypto/acme/autocert" "golang.org/x/crypto/acme/autocert"
@@ -56,7 +57,12 @@ func Register(extend HandlerExtender) {
r := mux.NewRouter() r := mux.NewRouter()
corsRouter := 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 // Specific routes
r.HandleFunc("/ping", Ping).Methods("GET") r.HandleFunc("/ping", Ping).Methods("GET")