浏览代码

rpc: disable CORS if user has not specified custom config

Bas van Kervel 8 年之前
父节点
当前提交
a6af56fa4d
共有 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"},