فهرست منبع

Merge pull request #14399 from bas-vk/rpc-cors

rpc: disable CORS if user has not specified a custom config
Péter Szilágyi 8 سال پیش
والد
کامیت
5494e6e7ab
1فایلهای تغییر یافته به همراه5 افزوده شده و 0 حذف شده
  1. 5 0
      rpc/http.go

+ 5 - 0
rpc/http.go

@@ -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"},