From 5f5be4ec72876394814126ad6875b82f581a6aa1 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 25 十一月 2024 15:23:39 +0800
Subject: [PATCH] #
---
zy-acs-flow/.env | 8 ++------
zy-acs-flow/src/config/setting.js | 2 +-
zy-acs-flow/vite.config.js | 32 +++++++-------------------------
zy-acs-flow/src/utils/request.js | 2 +-
4 files changed, 11 insertions(+), 33 deletions(-)
diff --git a/zy-acs-flow/.env b/zy-acs-flow/.env
index a7366bc..5c79ede 100644
--- a/zy-acs-flow/.env
+++ b/zy-acs-flow/.env
@@ -1,6 +1,2 @@
-# COOL_BASE_IP = '10.242.136.69'
-COOL_BASE_IP = 'localhost'
-# COOL_BASE_IP = '10.10.10.200'
-# COOL_BASE_IP = '192.168.4.53'
-
-COOL_BASE_PORT = 8088
+COOL_BASE_IP=192.168.1.100
+COOL_BASE_PORT=8080
diff --git a/zy-acs-flow/src/config/setting.js b/zy-acs-flow/src/config/setting.js
index 83fea86..a2305fb 100644
--- a/zy-acs-flow/src/config/setting.js
+++ b/zy-acs-flow/src/config/setting.js
@@ -5,7 +5,7 @@
export const API_BASE_URL = 'http://' + IP + ':' + PORT + '';
-export const WEBSOCKET_BASE_URL = 'ws://' + IP + ':' + PORT + '';
+export const WEBSOCKET_BASE_URL = `${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}${window.location.host}`;
export const PREFIX_BASE_URL = '/api/';
diff --git a/zy-acs-flow/src/utils/request.js b/zy-acs-flow/src/utils/request.js
index f86e796..34c21ce 100644
--- a/zy-acs-flow/src/utils/request.js
+++ b/zy-acs-flow/src/utils/request.js
@@ -3,7 +3,7 @@
import { getToken, setToken, removeToken } from './token-util';
const service = axios.create({
- baseURL: API_BASE_URL + PREFIX_BASE_URL
+ baseURL: PREFIX_BASE_URL
});
/**
diff --git a/zy-acs-flow/vite.config.js b/zy-acs-flow/vite.config.js
index c824771..2d23684 100644
--- a/zy-acs-flow/vite.config.js
+++ b/zy-acs-flow/vite.config.js
@@ -3,32 +3,9 @@
import { resolve } from 'path';
// https://vitejs.dev/config/
-// export default defineConfig({
-// plugins: [react()],
-// resolve: {
-// alias: {
-// '@/': resolve('src') + '/'
-// }
-// },
-// server: {
-// port: 5000,
-// host: '0.0.0.0',
-// proxy: {
-// '/api': {
-// target: 'http://192.168.4.53:8088',
-// changeOrigin: true,
-// rewrite: (path) => path.replace(/^\/api/, ''),
-// },
-// },
-// },
-// base: './',
-// envPrefix: "COOL_",
-// });
-
-// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
-
+ console.log('Loaded environment variables:', env);
return {
plugins: [react()],
resolve: {
@@ -43,7 +20,12 @@
'/api': {
target: `http://${env.COOL_BASE_IP}:${env.COOL_BASE_PORT}`,
changeOrigin: true,
- rewrite: (path) => path.replace(/^\/api/, ''),
+ // rewrite: (path) => path.replace(/^\/api/, ''),
+ },
+ '/ws': {
+ target: `ws://${env.COOL_BASE_IP}:${env.COOL_BASE_PORT}`,
+ changeOrigin: true,
+ ws: true,
},
},
},
--
Gitblit v1.9.1