chore
This commit is contained in:
@@ -1,34 +1,37 @@
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { fileURLToPath, URL } from 'node:url';
|
||||
|
||||
import { defineConfig, ProxyOptions } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||
import { defineConfig, ProxyOptions } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
import vueDevTools from 'vite-plugin-vue-devtools';
|
||||
|
||||
const apiProxyList: [string, string][] = [
|
||||
['/minio', 'http://172.16.6.248:9002'],
|
||||
// ['/api', 'http://172.16.6.248:18760/api'],
|
||||
['/api', 'http://localhost:3000/api'],
|
||||
['/10/api', 'http://localhost:3000/api'],
|
||||
['/11/api', 'http://localhost:3000/api'],
|
||||
]
|
||||
// ['/api', 'http://localhost:3000/api'],
|
||||
// ['/10/api', 'http://localhost:3000/api'],
|
||||
// ['/11/api', 'http://localhost:3000/api'],
|
||||
['/api', 'http://172.16.6.113:18760/api'],
|
||||
['/113/api', 'http://172.16.6.113:18760/api'],
|
||||
['/114/api', 'http://172.16.6.114:18760/api'],
|
||||
];
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig((/* { command, mode } */) => {
|
||||
const viteProxy: Record<string, string | ProxyOptions> = {}
|
||||
const viteProxy: Record<string, string | ProxyOptions> = {};
|
||||
apiProxyList.forEach((apiProxy) => {
|
||||
const [prefix, target] = apiProxy
|
||||
const [prefix, target] = apiProxy;
|
||||
viteProxy[prefix] = {
|
||||
target,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => {
|
||||
console.log(`请求路径: ${path}`)
|
||||
const rewrittenPath = path.replace(new RegExp(`^${prefix}`), '')
|
||||
console.log(`将代理到: ${target}${rewrittenPath}`)
|
||||
return rewrittenPath
|
||||
console.log(`请求路径: ${path}`);
|
||||
const rewrittenPath = path.replace(new RegExp(`^${prefix}`), '');
|
||||
console.log(`将代理到: ${target}${rewrittenPath}`);
|
||||
return rewrittenPath;
|
||||
},
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
plugins: [vue(), vueJsx(), vueDevTools()],
|
||||
@@ -41,5 +44,5 @@ export default defineConfig((/* { command, mode } */) => {
|
||||
port: 9654,
|
||||
proxy: viteProxy,
|
||||
},
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user