Skip to content

Commit

Permalink
fix(proxy-rewrite): do not invoke add_header if value resolved as nil (
Browse files Browse the repository at this point in the history
  • Loading branch information
fengxsong authored Dec 11, 2023
1 parent c12002e commit e6afb6f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions apisix/plugins/proxy-rewrite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,11 @@ function _M.rewrite(conf, ctx)
local val = core.utils.resolve_var_with_captures(hdr_op.add[i + 1],
ctx.proxy_rewrite_regex_uri_captures)
val = core.utils.resolve_var(val, ctx.var)
local header = hdr_op.add[i]
core.request.add_header(ctx, header, val)
-- A nil or empty table value will cause add_header function to throw an error.
if val then
local header = hdr_op.add[i]
core.request.add_header(ctx, header, val)
end
end

local field_cnt = #hdr_op.set
Expand Down

0 comments on commit e6afb6f

Please sign in to comment.