mod_http: Use http_default_host for URLs generated in global context
authorKim Alvefur <zash@zash.se>
Fri, 04 Feb 2022 19:58:43 +0100
changeset 12272 d41e8c7890b0
parent 12271 a52a0680fcd8
child 12273 a19d435dee90
mod_http: Use http_default_host for URLs generated in global context This might make the global routes less confusing sometimes, or at least valid URLs instead of http://*:5280/ which doesn't make much sense.
plugins/mod_http.lua
--- a/plugins/mod_http.lua	Fri Feb 04 19:04:32 2022 +0100
+++ b/plugins/mod_http.lua	Fri Feb 04 19:58:43 2022 +0100
@@ -94,7 +94,8 @@
 		for port, service in pairs(ports) do -- luacheck: ignore 512
 			local url = {
 				scheme = service[1].service.name;
-				host = module:get_option_string("http_host", module.host);
+				host = module:get_option_string("http_host", module.global
+					and module:get_option_string("http_default_host") or module.host);
 				port = port;
 				path = get_base_path(module, app_name, default_path or "/" .. app_name);
 			}