diff --git a/internal/debugserver/grpcui.go b/internal/debugserver/grpcui.go index a6e67f85a8d..34420b584ef 100644 --- a/internal/debugserver/grpcui.go +++ b/internal/debugserver/grpcui.go @@ -6,12 +6,15 @@ import ( "github.com/fullstorydev/grpcui/standalone" "github.com/sourcegraph/log" + "github.com/sourcegraph/sourcegraph/internal/env" "google.golang.org/grpc" "github.com/sourcegraph/sourcegraph/internal/grpc/defaults" "github.com/sourcegraph/sourcegraph/lib/errors" ) +var envEnableGRPCWebUI = env.MustGetBool("GRPC_WEB_UI_ENABLED", false, "Enable the gRPC Web UI to debug and explore gRPC services") + const gRPCWebUIPath = "/debug/grpcui" // NewGRPCWebUIEndpoint returns a new Endpoint that serves a gRPC Web UI instance @@ -50,6 +53,11 @@ type grpcHandler struct { } func (g *grpcHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if !envEnableGRPCWebUI { + http.Error(w, "gRPC Web UI is disabled", http.StatusNotFound) + return + } + ctx := r.Context() cc, err := grpc.DialContext(ctx, g.target, g.dialOpts...) diff --git a/sg.config.yaml b/sg.config.yaml index befbd0299e1..304a82fa570 100644 --- a/sg.config.yaml +++ b/sg.config.yaml @@ -119,6 +119,9 @@ env: # OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318 # OTEL_EXPORTER_OTLP_PROTOCOL: http/json + # Enable gRPC Web UI for debugging + GRPC_WEB_UI_ENABLED: "true" + # Enable full protobuf message logging when an internal error occurred SRC_GRPC_INTERNAL_ERROR_LOGGING_LOG_PROTOBUF_MESSAGES_ENABLED: "true" SRC_GRPC_INTERNAL_ERROR_LOGGING_LOG_PROTOBUF_MESSAGES_JSON_TRUNCATION_SIZE_BYTES: "1KB"