diff --git a/apisix/plugins/grpc-web.lua b/apisix/plugins/grpc-web.lua index 147004a966d5..a528985d9a8f 100644 --- a/apisix/plugins/grpc-web.lua +++ b/apisix/plugins/grpc-web.lua @@ -32,7 +32,7 @@ local DEFAULT_PROXY_CONTENT_TYPE = "application/grpc" local DEFAULT_CORS_ALLOW_EXPOSE_HEADERS = "grpc-status,grpc-message" local GRPC_WEB_TRAILER_FRAME_HEADER = string.char(128, 0, 0, 0) -local GRPC_WEB_REQUIRED_TRAILERS_DEFAULT_VALUES = { +local GRPC_WEB_REQ_TRAILERS_DEFAULT = { ["grpc-status"] = "0", ["grpc-message"] = "OK" } @@ -177,7 +177,7 @@ function _M.body_filter(conf, ctx) if response and string.len(response) ~= 0 then local headers = ngx.resp.get_headers() local trailers = " " - for trailer_key, trailer_default_value in pairs(GRPC_WEB_REQUIRED_TRAILERS_DEFAULT_VALUES) do + for trailer_key, trailer_default_value in pairs(GRPC_WEB_REQ_TRAILERS_DEFAULT) do local trailer_value = headers[trailer_key] if trailer_value == nil then diff --git a/t/plugin/grpc-web.t b/t/plugin/grpc-web.t index 75b9a2efdd81..b9c35c81182a 100644 --- a/t/plugin/grpc-web.t +++ b/t/plugin/grpc-web.t @@ -228,6 +228,8 @@ Content-Type: application/grpc-web Access-Control-Allow-Origin: http://test.com Content-Type: application/grpc-web + + === TEST 11: grpc-web access control expose headers for non grpc servers that don't implement grpc-web --- request POST /grpc/web/a6.RouteService/GetRoute @@ -239,4 +241,3 @@ Content-Type: application/grpc-web Access-Control-Allow-Origin: http://test.com Content-Type: application/grpc-web Access-Control-Expose-Headers: grpc-status,grpc-message -