diff --git a/app.py b/app.py
index 15001d2..3fbeb2f 100644
--- a/app.py
+++ b/app.py
@@ -7,6 +7,7 @@ app = Flask(__name__, )
sock = Sock(app)
+
app.wsgi_app = prefix.PrefixMiddleware(
app.wsgi_app, prefix=os.environ.get("URL_PREFIX", "")
)
@@ -17,7 +18,7 @@ def index():
return render_template('index.html')
-@sock.route('/echo')
+@sock.route('/echo/')
def echo(sock):
while True:
data = sock.receive()
diff --git a/templates/index.html b/templates/index.html
index c091cc6..4e402c2 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -18,10 +18,23 @@
).innerHTML += `${text}
`;
};
+ console.log(location.protocol);
+ console.log(
+ location.protocol == "https:"
+ ? "wss://"
+ : "ws://" +
+ location.host +
+ location.pathname.replace(new RegExp("\/" + "$"), "") +
+ "/echo/"
+ );
+
const socket = new WebSocket(
- location.protocol == "https"
+ location.protocol == "https:"
? "wss://"
- : "ws://" + location.host + location.pathname + "/echo/"
+ : "ws://" +
+ location.host +
+ location.pathname.replace(new RegExp("\/" + "$"), "") +
+ "/echo/"
);
socket.addEventListener("message", (ev) => {
log("<<< " + ev.data, "blue");