-
Can I get URL of my NetBox instance from a NetBox custom script? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In general, your Netbox instance may be accessed via many URLs which all resolve to the same host. Hence you probably want to look at the Request object to see how the user is currently accessing it: Look at how the SVG code creates an absolute base URL: Or you may be able to use the django 'reverse' method: |
Beta Was this translation helpful? Give feedback.
In general, your Netbox instance may be accessed via many URLs which all resolve to the same host.
Hence you probably want to look at the Request object to see how the user is currently accessing it:
https://netbox.readthedocs.io/en/stable/additional-features/custom-scripts/#accessing-request-data
Look at how the SVG code creates an absolute base URL:
https://github.com/netbox-community/netbox/blob/v2.11.12/netbox/dcim/api/views.py#L216
Or you may be able to use the django 'reverse' method:
https://github.com/netbox-community/netbox/blob/v2.11.12/netbox/dcim/models/devices.py#L643-L644