Use os.env's PORT as a default in BASE_URL

This commit is contained in:
Klaas van Schelven
2024-11-06 09:45:50 +01:00
parent 488b52ea04
commit 81722776c1
2 changed files with 7 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
# approach as in snappea/settings.py
# alternative would be: just put "everything" in the big settings.py (or some mix-using-imports version of that).
# but for now I like the idea of keeping the bugsink-as-an-app stuff separate from the regular Django/db/global stuff.
import os
from contextlib import contextmanager
from django.conf import settings
@@ -17,8 +18,11 @@ CB_ADMINS = "CB_ADMINS"
CB_NOBODY = "CB_NOBODY"
_PORT = os.environ.get("PORT", "8000")
DEFAULTS = {
"BASE_URL": "http://127.0.0.1:8000", # no trailing slash
"BASE_URL": f"http://127.0.0.1:{_PORT}", # no trailing slash
"SITE_TITLE": "Bugsink", # you can customize this as e.g. "My Bugsink" or "Bugsink for My Company"
# Users, teams, projects

View File

@@ -8,6 +8,7 @@ from bugsink.settings.default import DATABASES
_KIBIBYTE = 1024
_MEBIBYTE = 1024 * _KIBIBYTE
_PORT = os.environ.get("PORT", "8000")
DEBUG = os.getenv("DEBUG", "False").lower() in ("true", "1", "yes")
@@ -93,7 +94,7 @@ BUGSINK = {
"DIGEST_IMMEDIATELY": False, # hard-coded, corresponds to Docker setup
# The URL where the Bugsink instance is hosted. This is used in the email notifications and to construct DSNs.
"BASE_URL": os.getenv("BASE_URL", "http://localhost:8000"), # no trailing slash
"BASE_URL": os.getenv("BASE_URL", f"http://localhost:{_PORT}"), # no trailing slash
# you can customize this as e.g. "My Bugsink" or "Bugsink for My Company"
"SITE_TITLE": os.getenv("SITE_TITLE", "Bugsink"),