Skip to content

Commit 37a1c9e

Browse files
committed
add wss check and allowed hosts
1 parent 0b107aa commit 37a1c9e

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

samples/django-channels-redis/app/chat/templates/chat/room.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@
102102

103103
messages.forEach(appendMessage)
104104

105-
const chatSocket = new WebSocket('ws://' + window.location.host + '/ws/' + roomName + '/')
105+
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://'
106+
const chatSocket = new WebSocket(protocol + window.location.host + '/ws/' + roomName + '/')
106107

107108
chatSocket.onmessage = function (e) {
108109
const data = JSON.parse(e.data)

samples/django-channels-redis/app/django_defang/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# SECURITY WARNING: don't run with debug turned on in production!
3030
DEBUG = os.getenv("DEBUG", False) == "True"
3131

32-
ALLOWED_HOSTS = []
32+
ALLOWED_HOSTS = ['*.prod1.defang.dev'] # Set this to your domain name
3333

3434
if DEBUG:
3535
ALLOWED_HOSTS = ["*"]

samples/django-channels-redis/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
healthcheck:
1616
# wget or curl required for healthchecks on services with a published port
1717
# this gets parsed by Defang and provided to the load balancers as well
18-
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/"]
18+
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8000/"]
1919

2020
redis_service:
2121
image: redis:6.2

0 commit comments

Comments
 (0)