netbox in subfolder: api search is not working for tags #2474

Closed
opened 2025-12-29 18:19:10 +01:00 by adam · 1 comment
Owner

Originally created by @lwillek on GitHub (Mar 20, 2019).

Environment

  • Python version: 2.7.16rc1
  • NetBox version: 2.5.8

If you install netbox as usual, but configure a subfolder like https://mydomain.org/netbox to access your installation, then you have to set the BASE_PATH in configuration.py and nearly everything works like a charm.

Unfortunately working with tags is difficult, because the Ajax results could not be loaded if you try to search or modify tags with help of the ui.
The reason is that within the static javascript, the var netbox_api_path is not used. Instead, the api url is hardcoded: https://github.com/digitalocean/netbox/blob/develop/netbox/project-static/js/forms.js#L253

The solution is easy: just use the variable, i.e url: netbox_api_path + 'extras/tags/', instead of url: "/api/extras/tags/",

A quick workaround without adapting the code is to rewrite the incoming requests. For Apache this config will do the job:

        RewriteEngine  on
        RewriteRule    ^/api/(.*)      /netbox/api/$1 [R=permanent]

I will write a small patch to avoid the "rewrite" workaround.

Originally created by @lwillek on GitHub (Mar 20, 2019). ### Environment * Python version: 2.7.16rc1 * NetBox version: 2.5.8 If you install netbox as usual, but configure a subfolder like `https://mydomain.org/netbox` to access your installation, then you have to set the BASE_PATH in configuration.py and nearly everything works like a charm. Unfortunately working with tags is difficult, because the Ajax results could not be loaded if you try to search or modify tags with help of the ui. The reason is that within the static javascript, the var `netbox_api_path` is not used. Instead, the api url is hardcoded: https://github.com/digitalocean/netbox/blob/develop/netbox/project-static/js/forms.js#L253 The solution is easy: just use the variable, i.e `url: netbox_api_path + 'extras/tags/',` instead of `url: "/api/extras/tags/",` A quick workaround without adapting the code is to rewrite the incoming requests. For Apache this config will do the job: ``` RewriteEngine on RewriteRule ^/api/(.*) /netbox/api/$1 [R=permanent] ``` I will write a small patch to avoid the "rewrite" workaround.
adam added the type: bugstatus: accepted labels 2025-12-29 18:19:10 +01:00
adam closed this issue 2025-12-29 18:19:10 +01:00
Author
Owner

@lampwins commented on GitHub (Mar 21, 2019):

Thanks for this. I noticed you opened a PR in your fork with the fix, would you mind opening one here?

@lampwins commented on GitHub (Mar 21, 2019): Thanks for this. I noticed you opened a PR in your fork with the fix, would you mind opening one here?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2474