Skip to content

Commit ae4e5e0

Browse files
committed
thjs-51: * fix socket connection
1 parent 62f4153 commit ae4e5e0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { io } from 'socket.io-client';
22

33
class Socket {
4-
getInstance = namespace => io(namespace);
4+
getInstance = (namespace) => {
5+
return io(namespace, {
6+
transports: ['websocket']
7+
});
8+
};
59
}
610

711
export { Socket };

client/vite.config.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dns.setDefaultResultOrder('verbatim');
88

99
const config = ({ mode }) => {
1010
// import.meta.env doesn't exist at this moment
11-
const { VITE_PORT, VITE_HOST, VITE_API_PATH, VITE_API_SERVER } = loadEnv(
11+
const { VITE_PORT, VITE_HOST, VITE_API_PATH, VITE_API_SERVER, VITE_SOCKET_SERVER } = loadEnv(
1212
mode,
1313
process.cwd()
1414
);
@@ -24,7 +24,11 @@ const config = ({ mode }) => {
2424
host: VITE_HOST,
2525
port: Number(VITE_PORT),
2626
proxy: {
27-
[VITE_API_PATH]: VITE_API_SERVER
27+
[VITE_API_PATH]: VITE_API_SERVER,
28+
'/socket.io': {
29+
target: VITE_SOCKET_SERVER,
30+
ws: true,
31+
},
2832
}
2933
},
3034
plugins: [reactPlugin()]

0 commit comments

Comments
 (0)