ASP.NET Core › gRPC Services
Why can't browsers natively call gRPC services directly, and what is gRPC-Web, and how does it solve this?
IntermediateAnswer
Standard gRPC requires full HTTP/2 features (particularly trailers, sent after the response body, used to carry the final status) that browser JavaScript fetch/XHR APIs don't expose access to -- gRPC-Web is a protocol variant designed to work within browser HTTP/1.1 and HTTP/2 constraints (encoding trailers differently, within the body), requiring a compatible client library on the frontend and either native gRPC-Web support on the server or a proxy (like Envoy) translating between gRPC-Web and standard gRPC for the backend service.
// Program.cs -- enabling gRPC-Web support directly in ASP.NET Core
builder.Services.AddGrpc();
var app = builder.Build();
app.UseGrpcWeb();
app.MapGrpcService<GreeterService>().EnableGrpcWeb();Real-world example A single-page application needs to call a gRPC backend service directly from browser JavaScript, so the team enables ASP.NET Core's built-in gRPC-Web support on the server and uses the grpc-web client library on the frontend, avoiding the need for a separate Envoy proxy.