fix: base_url

This commit is contained in:
barredterra 2020-12-21 17:25:16 +01:00
parent 689e39acf9
commit 9f6fc4618f

View file

@ -21,11 +21,13 @@ class ConnectedApp(Document):
"""
def validate(self):
try:
base_url = frappe.request.host_url
except RuntimeError:
# for tests
base_url = frappe.get_site_config().host_name or 'http://localhost:8000'
if not frappe.flags.in_test:
try:
base_url = frappe.request.host_url
except RuntimeError:
base_url = frappe.utils.get_url()
else:
base_url = 'http://localhost:8000'
callback_path = '/api/method/frappe.integrations.doctype.connected_app.connected_app.callback/' + self.name
self.redirect_uri = urljoin(base_url, callback_path)