rpc: disable CORS if user has not specified custom config

This commit is contained in:
Bas van Kervel 2017-05-02 11:14:40 +02:00
parent 5884606ec3
commit a6af56fa4d
No known key found for this signature in database
GPG Key ID: BFB23B252EF5812B

View File

@ -162,6 +162,11 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func newCorsHandler(srv *Server, allowedOrigins []string) http.Handler {
// disable CORS support if user has not specified a custom CORS configuration
if len(allowedOrigins) == 0 {
return srv
}
c := cors.New(cors.Options{
AllowedOrigins: allowedOrigins,
AllowedMethods: []string{"POST", "GET"},