grpc_web

Translates gRPC-Web calls to native gRPC and back.

Versions marked “overview” do not contain this page. Selecting one opens that version’s documentation overview.

On this page

Translates gRPC-Web calls to native gRPC and back.

Configuration Notes

Browsers cannot speak gRPC: they have no access to HTTP/2 trailers, which is where a call’s status lives. gRPC-Web keeps the same length-prefixed framing but moves the trailers into the body as one final frame, and optionally base64-encodes the whole stream so it survives an XMLHttpRequest.

This filter rewrites the request’s content-type to native gRPC (decoding the body first for the -text variant), rewrites the response’s content-type back, and converts the upstream response trailers into the trailer frame the browser expects. A Trailers-Only response needs no frame: it carries the status in its header block and has no body to append to, and that is where a gRPC-Web client looks for it.

Requires an HTTP/2 upstream (clusters[].http.version: h2): trailers exist on no other leg, so there would be nothing to translate.

Non-gRPC-Web requests pass through untouched.

Configuration

FieldTypeRequiredDescription
encodingsEncodingsyesDownstream encodings to translate.
encodings.binaryboolyesAccept application/grpc-web[+codec] — raw frames.
encodings.textboolyesAccept application/grpc-web-text[+codec] — base64 frames.
max_buffer_bytesintegeryesMaximum bytes buffered while decoding a base64 request body.
on_missing_trailerssynthesize | passthroughyesBehaviour when the upstream response carries no gRPC status.

Example

filter: grpc_web
encodings:
  binary: true
  text: true
max_buffer_bytes: 10485760
on_missing_trailers: synthesize   # synthesize | passthrough