Skip to content

Commit

Permalink
[chores] Updated tldextract and made ROOT_DOMAIN logic consistent
Browse files Browse the repository at this point in the history
A variable called ROOT_DOMAIN was computed with different
methods in nginx and base image.
The approach using the tldextract library seems more robust,
therefore I decided to update the library and change the
base image settings code accordingly.
  • Loading branch information
nemesifier committed May 22, 2024
1 parent 128b0f1 commit b8a0f94
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion images/common/openwisp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import sys

import tldextract
from openwisp.utils import (
env_bool,
is_string_env_bool,
Expand All @@ -28,8 +29,8 @@
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = os.environ['DJANGO_SECRET_KEY']
DEBUG = env_bool(os.environ['DEBUG_MODE'])
ROOT_DOMAIN = f'.{".".join(os.environ["DASHBOARD_DOMAIN"].split(".")[1:])}'
MAX_REQUEST_SIZE = int(os.environ['NGINX_CLIENT_BODY_SIZE']) * 1024 * 1024
ROOT_DOMAIN = '.' + tldextract.extract(os.environ["DASHBOARD_DOMAIN"]).registered_domain
INSTALLED_APPS = []

if 'DJANGO_ALLOWED_HOSTS' not in os.environ:
Expand Down
1 change: 1 addition & 0 deletions images/openwisp_base/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ django-cors-headers~=3.1 # allows 3.x and > 3.1
django-pipeline~=2.0 # allows 2.x
uwsgi~=2.0.20
django-celery-email~=3.0.0
tldextract~=5.1.2
# these add support for object storage
# (eg: Amazon S3, GCS)
django-storages~=1.12.3
Expand Down
2 changes: 1 addition & 1 deletion images/openwisp_nginx/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
tldextract~=3.2.0
tldextract~=5.1.2

0 comments on commit b8a0f94

Please sign in to comment.