Skip to content

Commit 997aea7

Browse files
Update settings.py to support dynamic Codespace URL in ALLOWED_HOSTS
1 parent 24ca478 commit 997aea7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

octofit-tracker/backend/octofit_tracker/settings.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
2727

28-
ALLOWED_HOSTS = ['*']
28+
import os
29+
CODESPACE_NAME = os.environ.get('CODESPACE_NAME')
30+
codespace_host = f"{CODESPACE_NAME}-8000.app.github.dev" if CODESPACE_NAME else None
31+
ALLOWED_HOSTS = ['localhost', '127.0.0.1']
32+
if codespace_host:
33+
ALLOWED_HOSTS.append(codespace_host)
2934

3035

3136
# Application definition

0 commit comments

Comments
 (0)