package server import ( "net/http" "github.com/rs/cors" ) func configureCORSFor(handler http.Handler, origins []string) http.Handler { ch := cors.New(cors.Options{ // # http://mywebsite-domain.com/ is configured in hosts (localhost:80 alias) AllowedOrigins: origins, AllowedMethods: []string{ http.MethodPost, http.MethodGet, http.MethodPut, http.MethodDelete, // http.MethodOptions, }, OptionsPassthrough: false, AllowCredentials: true, // Debug: true, }) return ch.Handler(handler) }