Update vite.config.ts
This commit is contained in:
parent
4738c1c57a
commit
0fae54e093
@ -1,14 +1,14 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import { fileURLToPath, URL } from 'node:url'
|
||||
import { defineConfig } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
|
||||
const BAIDU_ORIGIN = 'https://gushitong.baidu.com'
|
||||
const BAIDU_ORIGIN = "https://gushitong.baidu.com";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
@ -17,51 +17,53 @@ export default defineConfig({
|
||||
* WebSocket must be registered before `/baidu` so it is not swallowed.
|
||||
* Baidu rejects non-baidu Origins (localhost → 403); rewrite Origin here.
|
||||
*/
|
||||
'/finance-ws': {
|
||||
target: 'wss://finance-ws.pae.baidu.com',
|
||||
"/finance-ws": {
|
||||
target: "wss://finance-ws.pae.baidu.com",
|
||||
changeOrigin: true,
|
||||
ws: true,
|
||||
rewrite: (path) => path.replace(/^\/finance-ws/, '') || '/',
|
||||
rewrite: (path) => path.replace(/^\/finance-ws/, "") || "/",
|
||||
configure: (proxy) => {
|
||||
const setBaiduHeaders = (proxyReq: { setHeader: (k: string, v: string) => void }) => {
|
||||
proxyReq.setHeader('Origin', BAIDU_ORIGIN)
|
||||
proxyReq.setHeader('Referer', `${BAIDU_ORIGIN}/`)
|
||||
}
|
||||
proxy.on('proxyReq', setBaiduHeaders)
|
||||
proxy.on('proxyReqWs', setBaiduHeaders)
|
||||
const setBaiduHeaders = (proxyReq: {
|
||||
setHeader: (k: string, v: string) => void;
|
||||
}) => {
|
||||
proxyReq.setHeader("Origin", BAIDU_ORIGIN);
|
||||
proxyReq.setHeader("Referer", `${BAIDU_ORIGIN}/`);
|
||||
};
|
||||
proxy.on("proxyReq", setBaiduHeaders);
|
||||
proxy.on("proxyReqWs", setBaiduHeaders);
|
||||
},
|
||||
},
|
||||
'/baidu': {
|
||||
target: 'https://finance.pae.baidu.com',
|
||||
"/baidu": {
|
||||
target: "https://finance.pae.baidu.com",
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/baidu/, ''),
|
||||
rewrite: (path) => path.replace(/^\/baidu/, ""),
|
||||
headers: {
|
||||
Referer: `${BAIDU_ORIGIN}/`,
|
||||
'User-Agent':
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
||||
"User-Agent":
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||
},
|
||||
},
|
||||
/** 同花顺 dq 数据源(主力异动等);须排在 /jqka 前,避免前缀被吞 */
|
||||
'/dq': {
|
||||
target: 'https://dq.10jqka.com.cn',
|
||||
"/dq": {
|
||||
target: "https://dq.10jqka.com.cn",
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/dq/, ''),
|
||||
rewrite: (path) => path.replace(/^\/dq/, ""),
|
||||
},
|
||||
'/jqka': {
|
||||
target: 'https://fupage.10jqka.com.cn',
|
||||
"/jqka": {
|
||||
target: "https://fupage.10jqka.com.cn",
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/jqka/, ''),
|
||||
rewrite: (path) => path.replace(/^\/jqka/, ""),
|
||||
},
|
||||
'/deepseek': {
|
||||
target: 'https://api.deepseek.com',
|
||||
"/deepseek": {
|
||||
target: "https://api.deepseek.com",
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/deepseek/, ''),
|
||||
rewrite: (path) => path.replace(/^\/deepseek/, ""),
|
||||
},
|
||||
'/uuquant': {
|
||||
target: 'http://162.14.77.110:18880',
|
||||
"/uuquant": {
|
||||
target: "http://162.14.77.110:8888",
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/uuquant/, ''),
|
||||
rewrite: (path) => path.replace(/^\/uuquant/, ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user