Keypair generation does not work when rebasing URL #658

Closed
opened 2025-12-29 16:24:30 +01:00 by adam · 2 comments
Owner

Originally created by @specialcircumstances on GitHub (Jan 23, 2017).

I have a couple of instances of Netbox running, and to seperate them I rebase them behind nginx locations and use BASE_PATH = 'instancexx/'
e.g.
/opt/netbox/instance/instance01 ->> mynetboxserver/instance01
/opt/netbox/instance/instance01 ->> mynetboxserver/instance02

All works OK so far as I've found, but the generate keys does not. I've traced through as far as I can, and I think the problem is in secrets.js, as the URL linked to the button doesn't get rebased by the mechanism in the main urls.py, so instead of:

https://mynetboxserver/instance01/api/secrets/generate-keys/

the request is for:

https://mynetboxserver/api/secrets/generate-keys/

which of course does not work.

I think the issue is here at line 51 of secrets.js:

url: '/api/secrets/generate-keys/',

I'm not much good with JS, so I can't offer a solution off the cuff, but hopefully it'll be an easy fix?

PS I've also spotted a similar issue around the unlock in the same JS.

Originally created by @specialcircumstances on GitHub (Jan 23, 2017). I have a couple of instances of Netbox running, and to seperate them I rebase them behind nginx locations and use BASE_PATH = 'instancexx/' e.g. /opt/netbox/instance/instance01 ->> mynetboxserver/instance01 /opt/netbox/instance/instance01 ->> mynetboxserver/instance02 All works OK so far as I've found, but the generate keys does not. I've traced through as far as I can, and I think the problem is in secrets.js, as the URL linked to the button doesn't get rebased by the mechanism in the main urls.py, so instead of: `https://mynetboxserver/instance01/api/secrets/generate-keys/` the request is for: `https://mynetboxserver/api/secrets/generate-keys/` which of course does not work. I think the issue is here at line 51 of secrets.js: ` url: '/api/secrets/generate-keys/',` I'm not much good with JS, so I can't offer a solution off the cuff, but hopefully it'll be an easy fix? PS I've also spotted a similar issue around the unlock in the same JS.
adam added the type: bug label 2025-12-29 16:24:30 +01:00
adam closed this issue 2025-12-29 16:24:30 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 23, 2017):

This was due to a lingering hard-coded reference to the API path, from before the introduction of BASE_PATH. We can fix it by recording BASE_PATH as a Javascript variable within the base template and referring to it for all API calls.

I'm not much good with JS

Neither am I, as can be confirmed by reviewing any of the custom Javascript included with NetBox.

@jeremystretch commented on GitHub (Jan 23, 2017): This was due to a lingering hard-coded reference to the API path, from before the introduction of `BASE_PATH`. We can fix it by recording `BASE_PATH` as a Javascript variable within the base template and referring to it for all API calls. > I'm not much good with JS Neither am I, as can be confirmed by reviewing any of the custom Javascript included with NetBox.
Author
Owner

@specialcircumstances commented on GitHub (Jan 23, 2017):

Thanks for the quick fix 😀

@specialcircumstances commented on GitHub (Jan 23, 2017): Thanks for the quick fix 😀
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#658