diff --git a/src/views/Logs.vue b/src/views/Logs.vue index ba112f6..02a0a56 100644 --- a/src/views/Logs.vue +++ b/src/views/Logs.vue @@ -61,7 +61,8 @@ export default { const connectWebSocket = () => { const token = getCookie('token'); const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - const wsUrl = `${wsProtocol}//localhost:8080/system/getLogs?token=${token}`; + const target = __APP_TARGET__; + const wsUrl = `${wsProtocol}//${target}/system/getLogs?token=${token}`; socket.value = new WebSocket(wsUrl); diff --git a/vite.config.js b/vite.config.js index 2a624ba..5c81400 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,14 +1,19 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' +const APP_TARGET = '192.168.1.4:38080' + export default defineConfig({ + define: { + __APP_TARGET__: JSON.stringify(APP_TARGET) + }, plugins: [vue()], server: { host: '0.0.0.0', port: 3000, proxy: { '/api': { - target: 'http://192.168.1.4:38080', + target: `http://${APP_TARGET}`, changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, '') }