title | keywords | description | ||||
---|---|---|---|---|---|---|
grpc-web |
|
This document contains information about the Apache APISIX grpc-web Plugin. |
The grpc-web
Plugin is a proxy Plugin that can process gRPC Web requests from JavaScript clients to a gRPC service.
You can enable the grpc-web
Plugin on a specific Route as shown below:
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
}
}
}'
:::info IMPORTANT
While using the grpc-web
Plugin, always using a prefix matching pattern (/*
, /grpc/example/*
) for matching Routes. This is because the gRPC Web client passes the package name, the service interface name, the method name and other information in the proto in the URI. For example, /path/a6.RouteService/Insert
.
So, when absolute matching is used, the Plugin would not be hit and the information from the proto would not be extracted.
:::
Refer to gRPC-Web Client Runtime Library or Apache APISIX gRPC Web Test Framework to learn how to setup your web client.
Once you have your gRPC Web client running, you can make a request to APISIX from the browser or through Node.js.
:::note
The supported request methods are POST
and OPTIONS
. See CORS support.
The supported Content-Type
includes application/grpc-web
, application/grpc-web-text
, application/grpc-web+proto
, and application/grpc-web-text+proto
. See Protocol differences vs gRPC over HTTP2.
:::
To disable the grpc-web
Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.
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
}
}
}'
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。