title: grpc-web

Description

The grpc-web plugin is a proxy plugin used to process gRPC Web client requests to gRPC Server.

gRPC Web Client -> APISIX -> gRPC server

How To Enable

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
        }
    }
}'

Test Plugin

Disable Plugin

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
        }
    }
}'