diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua index fa7bfc9bb4ed..5d814a091e4e 100644 --- a/apisix/cli/ngx_tpl.lua +++ b/apisix/cli/ngx_tpl.lua @@ -432,6 +432,11 @@ http { dns_resolver = dns_resolver, } apisix.http_init(args) + + -- set apisix_lua_home into constans module + -- it may be used by plugins to determine the work path of apisix + local constants = require("apisix.constants") + constants.apisix_lua_home = "{*apisix_lua_home*}" } init_worker_by_lua_block { diff --git a/t/APISIX.pm b/t/APISIX.pm index 26bf7efe66ce..070733c28708 100644 --- a/t/APISIX.pm +++ b/t/APISIX.pm @@ -490,6 +490,12 @@ _EOC_ dns_resolver = $dns_addrs_tbl_str, } apisix.http_init(args) + + -- set apisix_lua_home into constans module + -- it may be used by plugins to determine the work path of apisix + local constants = require("apisix.constants") + constants.apisix_lua_home = "$apisix_home" + $extra_init_by_lua _EOC_