Skip to content

Commit

Permalink
build: make web sockets work behind reverse proxy not at root.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmiscool committed Dec 19, 2024
1 parent a71d16a commit 5935375
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions public/doAjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ export async function doAjax(urlToCall, body) {




const getWebSocketURL = () => {
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const host = window.location.host;
const pathname = window.location.pathname.replace(/\/[^/]*$/, ''); // Remove the file name if present
return `${protocol}//${host}${pathname}/ws`;
};


class WebSocketClient {
constructor() {
this.url = window.location.protocol === "http:"? `ws://${window.location.host}` : `wss://${window.location.host}`;
this.url = getWebSocketURL();
this.socket = null;
}

Expand Down

0 comments on commit 5935375

Please sign in to comment.