feat: support gRPC-Web on frontend gRPC server (#8027)

feat: add gRPC-Web support using tonic-web

Signed-off-by: polar <palakjha916@gmail.com>
This commit is contained in:
Palak Jha
2026-04-24 12:18:15 +05:30
committed by GitHub
parent 10f3f59a01
commit aaa3f2cdf9
4 changed files with 26 additions and 1 deletions

View File

@@ -133,6 +133,7 @@ tokio-stream = { workspace = true, features = ["net"] }
tokio-util.workspace = true
tonic.workspace = true
tonic-reflection = "0.14"
tonic-web = "0.14"
tower = { workspace = true, features = ["full"] }
tower-http = { version = "0.6", features = ["full"] }
tracing.workspace = true

View File

@@ -355,7 +355,11 @@ impl Server for GrpcServer {
.layer(MetricsMiddlewareLayer)
.into_inner();
let mut builder = tonic::transport::Server::builder().layer(metrics_layer);
let mut builder = tonic::transport::Server::builder()
.accept_http1(true)
.layer(metrics_layer)
.layer(tonic_web::GrpcWebLayer::new());
if let Some(tls_config) = self.tls_config.clone() {
builder = builder.tls_config(tls_config).context(StartGrpcSnafu)?;
}