diff --git a/app/src/App.vue b/app/src/App.vue index 58f4090..8bade64 100644 --- a/app/src/App.vue +++ b/app/src/App.vue @@ -19,6 +19,7 @@ onMounted(async () => { socket.on('disconnect', function close() { console.log('Disconnected from the server.') }) + socket.on('message', console.log) }) diff --git a/app/src/components/TerminalPart.vue b/app/src/components/TerminalPart.vue index 2b61bf5..bdedd4d 100644 --- a/app/src/components/TerminalPart.vue +++ b/app/src/components/TerminalPart.vue @@ -55,11 +55,11 @@ onMounted(() => { term.open(terminal.value) term.focus() resizeScreen() - socket.on('message', (message) => { + socket.on('terminal', (message) => { term.write(message) }) term.onData((key) => { - socket.send(key) + socket.emit('terminal', key) }) }) diff --git a/app/src/utils/api.js b/app/src/utils/api.js index 61b68da..f598681 100644 --- a/app/src/utils/api.js +++ b/app/src/utils/api.js @@ -1,7 +1,7 @@ import axios from 'axios' const api = axios.create({ - baseURL: 'https://odyssey.wancat.cc/api/v1', + baseURL: '/api', }) export default api diff --git a/app/src/utils/socket.js b/app/src/utils/socket.js index 96c66e3..69050ca 100644 --- a/app/src/utils/socket.js +++ b/app/src/utils/socket.js @@ -1,7 +1,5 @@ import io from 'socket.io-client' -const host = 'wss://odyssey.wancat.cc' - class SocketWrapper { constructor() { this.socket = null @@ -14,7 +12,7 @@ class SocketWrapper { this.socket.disconnect() } - this.socket = io(host, { + this.socket = io('', { query: { session_id: session._id, }, diff --git a/app/vite.config.js b/app/vite.config.js index cf94bdc..c3d6440 100644 --- a/app/vite.config.js +++ b/app/vite.config.js @@ -7,8 +7,12 @@ export default defineConfig({ server: { proxy: { '/api': { - // target: 'http://localhost:3000', // the server url - target: 'http://odyssey.wancat.cc ', + target: 'http://localhost:3000/api/v1', + rewrite: (path) => path.replace(/^\/api/, ''), // Optional: remove "/api" prefix from the path + }, + '/socket.io': { + target: 'ws://localhost:3000', + // target: 'wss://odyssey.wancat.cc', ws: true, }, },