From 9ffd83af7d38ea35ecd621b2e06ee1f8b3eac13b Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Wed, 27 Apr 2022 10:10:54 +0200 Subject: [PATCH] fix: header matcher of grpc-web route (#3524) --- internal/api/api.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/api/api.go b/internal/api/api.go index 64859dce58..6a29364266 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -98,7 +98,13 @@ func (a *API) routeGRPC() { } func (a *API) routeGRPCWeb(router *mux.Router) { - router.NewRoute().HeadersRegexp("Content-Type", "application/grpc-web.*").Handler( + router.NewRoute().MatcherFunc( + func(r *http.Request, _ *mux.RouteMatch) bool { + if strings.Contains(r.Header.Get("content-type"), "application/grpc-web+") { + return true + } + return strings.Contains(r.Header.Get("access-control-request-headers"), "x-grpc-web") + }).Handler( grpcweb.WrapServer(a.grpcServer, grpcweb.WithAllowedRequestHeaders( []string{