diff --git a/views/plot.html b/views/plot.html
index f0b12da..5745331 100644
--- a/views/plot.html
+++ b/views/plot.html
@@ -130,7 +130,8 @@ Plotly.d3.csv("/1h.csv", function(err, rows){
Plotly.newPlot('graph', data, layout);
- var wsUri = window.location.toString().replace('http','ws') + "ws";
+ var url = window.location.toString().replace('http','ws');
+ var wsUri = url.substring(0, url.lastIndexOf("/")) + "/ws";
var connectSocket = function() {
websocket = new WebSocket(wsUri);
diff --git a/views/redeem.html b/views/redeem.html
index b7b0c11..0bb0600 100644
--- a/views/redeem.html
+++ b/views/redeem.html
@@ -133,7 +133,8 @@ Plotly.d3.csv("/{{ code }}.csv", function(err, rows){
Plotly.newPlot('graph', data, layout);
- var wsUri = window.location.toString().replace('http','ws') + "ws";
+ var url = window.location.toString().replace('http','ws');
+ var wsUri = url.substring(0, url.lastIndexOf("/")) + "/ws";
var connectSocket = function() {
websocket = new WebSocket(wsUri);