Use relative paths

Relative paths are helpful when running netbox behind a load balancer
where the client's path may not match what the server receives.

BASE_PATH can still be used to mimic the current behavior by setting:
BASE_PATH = '/'
This commit is contained in:
Logan V 2018-03-15 13:20:14 -05:00
parent 4acd8e180d
commit e23a785a14
4 changed files with 6 additions and 6 deletions

View File

@ -195,13 +195,13 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
STATIC_ROOT = BASE_DIR + '/static/'
STATIC_URL = '/{}static/'.format(BASE_PATH)
STATIC_URL = '{}static/'.format(BASE_PATH)
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "project-static"),
)
# Media
MEDIA_URL = '/{}media/'.format(BASE_PATH)
MEDIA_URL = '{}media/'.format(BASE_PATH)
# Disable default limit of 1000 fields per request. Needed for bulk deletion of objects. (Added in Django 1.10.)
DATA_UPLOAD_MAX_NUMBER_FIELDS = None
@ -212,7 +212,7 @@ MESSAGE_TAGS = {
}
# Authentication URLs
LOGIN_URL = '/{}login/'.format(BASE_PATH)
LOGIN_URL = '{}login/'.format(BASE_PATH)
# Secrets
SECRETS_MIN_PUBKEY_SIZE = 2048

View File

@ -67,7 +67,7 @@
<script src="{% static 'bootstrap-3.3.7-dist/js/bootstrap.min.js' %}"></script>
<script src="{% static 'js/forms.js' %}?v{{ settings.VERSION }}"></script>
<script type="text/javascript">
var netbox_api_path = "/{{ settings.BASE_PATH }}api/";
var netbox_api_path = "{{ settings.BASE_PATH }}api/";
var loading = $(".loading");
$(document).ajaxStart(function() {
loading.show();

View File

@ -1,5 +1,5 @@
{% extends 'rest_framework/base.html' %}
{% block branding %}
<a class="navbar-brand" href="/{{ settings.BASE_PATH }}">NetBox</a>
<a class="navbar-brand" href="{{ settings.BASE_PATH }}">NetBox</a>
{% endblock %}

View File

@ -188,7 +188,7 @@ class APISelect(SelectWithDisabled):
super(APISelect, self).__init__(*args, **kwargs)
self.attrs['class'] = 'api-select'
self.attrs['api-url'] = '/{}{}'.format(settings.BASE_PATH, api_url.lstrip('/')) # Inject BASE_PATH
self.attrs['api-url'] = '{}{}'.format(settings.BASE_PATH, api_url.lstrip('/')) # Inject BASE_PATH
if display_field:
self.attrs['display-field'] = display_field
if disabled_indicator: