apisix-dashboard
apisix-dashboard copied to clipboard
bug: 2.1 version create route with cors will cause an error
Bug report
Describe the bug
2.1 version create route with cors plugin and cors used the default setting {}, as below:
{"name":"test","uris":["/name"],"methods":["GET","HEAD","POST","PUT","DELETE","OPTIONS","PATCH"],"plugins":{"cors":{}},"vars":[],"upstream":{"type":"roundrobin","timeout":{"connect":6000,"send":6000,"read":6000},"nodes":[{"host":"127.0.0.1","port":7000,"weight":1}]}}
when request the route, will cause an error:
*104794 failed to run header_filter_by_lua*: /Users/idbeta/1106/apisix/apisix/plugins/cors.lua:89: bad argument #1 to 'str_find' (string expected, got nil)
stack traceback:
[C]: in function 'str_find'
/Users/idbeta/1106/apisix/apisix/plugins/cors.lua:89: in function 'create_obj_fun'
/Users/idbeta/1106/apisix/apisix/core/lrucache.lua:92: in function 'plugin_ctx'
/Users/idbeta/1106/apisix/apisix/plugins/cors.lua:168: in function 'phase_func'
/Users/idbeta/1106/apisix/apisix/init.lua:159: in function 'run_plugin'
/Users/idbeta/1106/apisix/apisix/init.lua:622: in function 'common_phase'
/Users/idbeta/1106/apisix/apisix/init.lua:632: in function 'http_header_filter_phase'
header_filter_by_lua:2: in main chunk while reading response header from upstream, client: 127.0.0.1, server: , request: "GET /name HTTP/1.1", upstream: "http://127.0.0.1:7000/name", host: "127.0.0.1:9080"
why test case PR will fix bug?
we can close this issue. @nic-chen please confirm again

Please add the fix PR of apisix
updated in the PR.
related issue in APISIX: https://github.com/apache/apisix/issues/2834 fixed by PR in APISIX: https://github.com/apache/apisix/pull/2856