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

Add option to serve with URL prefix #2008

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions backend/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool("DEBUG", True)

BASE_URL = env("BASE_URL", "/")

USE_X_FORWARDED_HOST = env.bool("USE_X_FORWARDED_HOST", False)

# Application definition
INSTALLED_APPS = [
"whitenoise.runserver_nostatic",
Expand Down Expand Up @@ -103,7 +107,7 @@

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = "/static/"
STATIC_URL = BASE_URL + "static/"
STATIC_ROOT = path.join(BASE_DIR, "staticfiles")
STATICFILES_DIRS = [
path.join(BASE_DIR, "client/dist/static"),
Expand Down Expand Up @@ -179,9 +183,9 @@
TEST_RUNNER = "xmlrunner.extra.djangotestrunner.XMLTestRunner"
TEST_OUTPUT_DIR = path.join(BASE_DIR, "junitxml")

LOGIN_URL = "/login/"
LOGIN_REDIRECT_URL = "/projects/"
LOGOUT_REDIRECT_URL = "/"
LOGIN_URL = BASE_URL + "login/"
LOGIN_REDIRECT_URL = BASE_URL + "projects/"
LOGOUT_REDIRECT_URL = BASE_URL

# Database
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
Expand Down Expand Up @@ -245,7 +249,7 @@

# User media files
MEDIA_ROOT = env("MEDIA_ROOT", path.join(BASE_DIR, "media"))
MEDIA_URL = "/media/"
MEDIA_URL = BASE_URL + "/media/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BASE_URL + "media/" ?


# Filepond settings
DJANGO_DRF_FILEPOND_UPLOAD_TMP = path.join(BASE_DIR, "filepond-temp-uploads")
Expand Down
3 changes: 3 additions & 0 deletions backend/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@
path("swagger/", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
re_path("", TemplateView.as_view(template_name="index.html")),
]

if settings.BASE_URL:
urlpatterns = [path(f'{settings.BASE_URL.strip("/")}/', include(urlpatterns))]
Comment on lines +67 to +68
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines seem to make the URL (e.g. http://127.0.0.1:8000/v1/projects) inaccessible. settings.BASE_URL is evaluated as True.

2 changes: 1 addition & 1 deletion frontend/components/configAutoLabeling/form/FileField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {
return {
myFiles: [],
server: {
url: '/v1/fp',
url: `${process.env.baseUrl}/fp`,
headers: {
'X-CSRFToken': Cookies.get('csrftoken')
},
Expand Down
7 changes: 6 additions & 1 deletion frontend/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import colors from 'vuetify/es5/util/colors'
import i18n from './i18n'

const BASE_URL = process.env.BASE_URL || '/'

export default {
router: {
base: BASE_URL
},
ssr: false,
/*
** Headers of the page
Expand All @@ -26,7 +31,7 @@ export default {
},

env: {
baseUrl: '/v1'
baseUrl: `${BASE_URL}v1`
},

/*
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/projects/_id/dataset/import.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default {
],
requiredRules: [(v) => !!v || 'Field value is required'],
server: {
url: '/v1/fp',
url: `${process.env.baseUrl}/fp`,
headers: {
'X-CSRFToken': Cookies.get('csrftoken')
},
Expand Down