The grpc-web
plugin is a proxy plugin used to process gRPC Web client requests to gRPC Server
.
gRPC Web Client -> APISIX -> gRPC server
To enable the gRPC Web
proxy plugin, routing must use the Prefix matching
pattern (for example: /*
or /grpc/example/*
), Because the gRPC Web
client will pass the package name
, service interface name
, method name
and other information declared in the proto
in the URI (for example: /path/a6.RouteService/Insert
) , When using Absolute Match
, it will not be able to hit the plugin and extract the proto
information.
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri":"/grpc/web/*", "plugins":{ "grpc-web":{} }, "upstream":{ "scheme":"grpc", "type":"roundrobin", "nodes":{ "127.0.0.1:1980":1 } } }'
POST
and OPTIONS
, refer to: CORS support.Content-Type
supports application/grpc-web
, application/grpc-web-text
, application/grpc-web+proto
, application/grpc-web-text+proto
, refer to: Protocol differences vs gRPC over HTTP2.gRPC Web
client is deployed, you can initiate a gRPC Web
proxy request to APISIX
through browser
or node
.Just delete the JSON configuration of grpc-web
in the plugin configuration. The APISIX plug-in is hot-reloaded, so there is no need to restart APISIX.
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri":"/grpc/web/*", "plugins":{}, "upstream":{ "scheme":"grpc", "type":"roundrobin", "nodes":{ "127.0.0.1:1980":1 } } }'