grpc_web
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
| Field | Type | Required | Description |
|---|---|---|---|
encodings | Encodings | yes | Downstream encodings to translate. |
encodings.binary | bool | yes | Accept application/grpc-web[+codec] — raw frames. |
encodings.text | bool | yes | Accept application/grpc-web-text[+codec] — base64 frames. |
max_buffer_bytes | integer | yes | Maximum bytes buffered while decoding a base64 request body. |
on_missing_trailers | synthesize | passthrough | yes | Behaviour 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