diff --git a/kyokusui/controller.py b/kyokusui/controller.py index 178d25e..56aee65 100644 --- a/kyokusui/controller.py +++ b/kyokusui/controller.py @@ -139,7 +139,8 @@ def retrieve(self, request): return Response.render(template, { "board": board, "thread": thread, - "boards": Board.list_subscribed(request.user) + "boards": Board.list_subscribed(request.user), + "ws_scheme": "ws" if request.scheme == "http" else "wss" }) def log(self, request): diff --git a/kyokusui/templates/thread.html b/kyokusui/templates/thread.html index 2fd7906..f424fc0 100644 --- a/kyokusui/templates/thread.html +++ b/kyokusui/templates/thread.html @@ -89,7 +89,7 @@ const textarea = document.querySelector("#message") const image_form = document.querySelector("#image") const image2send = document.querySelector("#image2send") -const ws = new WebSocket("{{ fullurl(request, "/api/v0/board/" + board._id + "/" + thread._id + "/socket", scheme="ws" if request.scheme == "http" else "wss") }}") +const ws = new WebSocket("{{ fullurl(request, "/api/v0/board/" + board._id + "/" + thread._id + "/socket", scheme=ws_scheme) }}") image_form.onchange = async e => { const files = await Promise.all(Array.from(e.target.files).map(f => { return new Promise((resolve, reject) => {