Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardcoded paths #212

Closed
Gelob opened this issue Jul 6, 2016 · 7 comments
Closed

Hardcoded paths #212

Gelob opened this issue Jul 6, 2016 · 7 comments
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@Gelob
Copy link
Contributor

Gelob commented Jul 6, 2016

Their are paths that are hardcoded in various files, this means if you want to run netbox in a subdirectory on an existing webserver you have to manually edit a lot of files.

@mdlayher
Copy link
Contributor

mdlayher commented Jul 6, 2016

To clarify, do you want to allow the root of the API to be specified via config? So if you set the root as /netbox/, an API call would be something like /netbox/api/ipam/vlans?

@jeremystretch jeremystretch added the type: bug A confirmed report of unexpected behavior in the application label Jul 6, 2016
@Gelob Gelob changed the title Hardcoded API paths Hardcoded paths Jul 6, 2016
@Gelob
Copy link
Contributor Author

Gelob commented Jul 6, 2016

@mdlayher The goal would be to be able to run netbox in a subdirectory and also have that subdirectory be named whatever we want. The hardcoded /api/ paths are a good example where this is an issue. We are currently doing this and I've included a diff of all the files we had to edit. I've had to edit out some other changes so the diff line numbers are not 100% accurate.

https://gist.github.com/Gelob/0914c3ee5219b70e63d15b2b70b9d9bc

My thought would be to have a variable in configuration.py to specify the path like BASE_URL but there may be better ways to handle this with Django or abstract it out so you don't have to specify.

@mdlayher
Copy link
Contributor

mdlayher commented Jul 6, 2016

Seems reasonable to me to have a base path like that prepended to NetBox paths, via a configuration option.

@Gelob
Copy link
Contributor Author

Gelob commented Jul 19, 2016

The upgrade.sh script should also detect the directory it is in and not hardcode paths

@iamdadmin
Copy link

iamdadmin commented Aug 31, 2016

Could we maybe get this roadmapped for 1.6? It's only a few variables which need to reference BASE_DN being either / or /netbox or /whatever_I_chose.

@iamdadmin
Copy link

iamdadmin commented Sep 1, 2016

Found a few more files with hardcoded paths for the API - the below prevent the 'Mark Connected' buttons from working.

netbox/templates/dcim/device.html: return toggleConnection($(this), "/api/dcim/console-ports/");
netbox/templates/dcim/device.html: return toggleConnection($(this), "/api/dcim/power-ports/");
netbox/templates/dcim/device.html: return toggleConnection($(this), "/api/dcim/interface-connections/");

And also in netbox/templates/_base.html you need to change this

            <a class="navbar-brand" href="/">
                <img src="{% static 'img/netbox_logo.png' %}" />
            </a>

To this (adjust for your subdirectory as needed) if you want the logo to redirect you to the location

            <a class="navbar-brand" href="/netbox">
                <img src="{% static 'img/netbox_logo.png' %}" />
            </a>

Of course, all this just replaces all the hardcoded paths with new ones.

@jeremystretch
Copy link
Member

833499f introduced BASE_PATH which allows the user to define an arbitrary URL path via which NetBox is accessed.

18a5a96 extended the APISelect widget to use BASE_PATH. This is a bit of a hack but should be sufficient until I get around to overhauling APISelect.

if-fi pushed a commit to if-fi/netbox that referenced this issue Oct 1, 2016
if-fi pushed a commit to if-fi/netbox that referenced this issue Oct 1, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

4 participants