Skip to content

Commit

Permalink
fix socket.io for proxied path
Browse files Browse the repository at this point in the history
  • Loading branch information
jancimertel committed May 11, 2023
1 parent f96ae8d commit 69e0857
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/client/src/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Api {

const url = new URL(baseUrl);

this.ws = io(baseUrl, { path: (url.pathname + "/socket.io").replace(`//`, '/') });
this.ws = io(url.origin, { path: (url.pathname + "/socket.io").replace(`//`, '/') });
this.ws.on("connect", () => {
console.log("Socket.IO connected");
});
Expand Down
2 changes: 2 additions & 0 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import "@service/mailer";
cors: {
origin: "*",
},
path: "/socket.io/",
});

socketio.on("connection", (socket: Socket) => {
console.log("new socket.io connection");
socket.on("ping", (callback) => {
Expand Down

0 comments on commit 69e0857

Please sign in to comment.