fix(get_url): allow disabling host header override

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-03-04 15:12:57 +05:30
parent 5886234b53
commit 627b8e04f5
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F
2 changed files with 7 additions and 3 deletions

View file

@ -442,7 +442,7 @@ class User(Document):
if password_expired:
url = "/update-password?key=" + key + "&password_expired=true"
link = get_url(url)
link = get_url(url, allow_header_override=False)
if send_email:
self.password_reset_mail(link)

View file

@ -1781,7 +1781,11 @@ def filter_strip_join(some_list: list[str], sep: str) -> list[str]:
return (cstr(sep)).join(cstr(a).strip() for a in filter(None, some_list))
def get_url(uri: str | None = None, full_address: bool = False) -> str:
def get_url(
uri: str | None = None,
full_address: bool = False,
allow_header_override: bool = True,
) -> str:
"""Get app url from request."""
host_name = frappe.local.conf.host_name or frappe.local.conf.hostname
@ -1791,7 +1795,7 @@ def get_url(uri: str | None = None, full_address: bool = False) -> str:
if not host_name:
request_host_name = get_host_name_from_request()
if request_host_name:
if request_host_name and allow_header_override:
host_name = request_host_name
elif frappe.local.site: