pynetbox
pynetbox copied to clipboard
Record.full_details() uses hostname in netbox response instead of the configured base url
I'm running Netbox in a Docker Container behind a reverse proxy. The Record.full_details() method fails because it uses the URL provided in the netbox result that points to 'http://127.0.0.1:8080'
There is a method that addresses this problem: Record._endpoint_from_url() But the full_details() method uses the raw url instead of the processed one.
I was able to fix this for me by just using self.endpoint.url instead of self.url. But I can't tell what implications that might have on other setups.
index 190c292..4fb8f83 100644
--- a/pynetbox/core/response.py
+++ b/pynetbox/core/response.py
@@ -417,7 +417,7 @@ class Record(object):
"""
if self.url:
req = Request(
- base=self.url,
+ base=self.endpoint.url,
token=self.api.token,
session_key=self.api.session_key,
http_session=self.api.http_session,
For me it looks like the correct solution is to configure the reverse proxy correctly (because as you said, the incorrect URL is in the data returned in your NetBox setup). Otherwise you will have other problems as well (like with pagination in .filter() calls and with links in rack diagrams).
If you are unsure about your reverse proxy configuration, you may want to open a discussion in NetBox repo, or search for existing configuration hints.
I'm going to close this as it seems invalid but feel free to ping me with more evidence to have it reopned.