Skip to content

Commit

Permalink
Merge pull request #131 from c3g/derived-chord-host
Browse files Browse the repository at this point in the history
Derive CHORD host from URL instead of using another env var
  • Loading branch information
davidlougheed committed Jun 4, 2020
2 parents b6ce8e3 + 1e106f8 commit cc79991
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions chord_metadata_service/metadata/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import sys
import logging

from urllib.parse import urlparse

from .. import __version__

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand All @@ -29,12 +31,6 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get("CHORD_DEBUG", "true").lower() == "true"

ALLOWED_HOSTS = [os.environ.get("CHORD_HOST", "localhost")]
if DEBUG:
ALLOWED_HOSTS = list(set(ALLOWED_HOSTS + ["localhost", "127.0.0.1", "[::1]"]))

APPEND_SLASH = False


# CHORD-specific settings

Expand All @@ -52,6 +48,16 @@
AUTH_OVERRIDE = not CHORD_PERMISSIONS


# Allowed hosts - TODO: Derive from CHORD_URL

CHORD_HOST = urlparse(CHORD_URL or "").netloc
ALLOWED_HOSTS = [CHORD_HOST or "localhost"]
if DEBUG:
ALLOWED_HOSTS = list(set(ALLOWED_HOSTS + ["localhost", "127.0.0.1", "[::1]"]))

APPEND_SLASH = False


# Application definition

INSTALLED_APPS = [
Expand Down

0 comments on commit cc79991

Please sign in to comment.