feat: 百度统计,处理vite代理后ip查询不可用问题
This commit is contained in:
+19
-5
@@ -37,13 +37,27 @@ export default defineConfig(({command, mode}) => {
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
'/v1/ip': {
|
||||
target: 'https://searchplugin.csdn.net', //ip查询
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
'^/api': ''
|
||||
}
|
||||
}
|
||||
rewrite: (path) => path.replace(/^\/v1\/ip/, '/api/v1/ip'),
|
||||
// bypass(req, res, options) {
|
||||
// console.log(1111)
|
||||
// const proxyUrl = new URL(options.rewrite(req.url) || '', (options.target) as string)?.href || ''
|
||||
// req.headers['x-req-proxyUrl'] = proxyUrl;
|
||||
// res.setHeader("x-res-proxyUrl", proxyUrl)
|
||||
// }
|
||||
},
|
||||
[env.VITE_APP_BASE_API] : {
|
||||
target: env.VITE_SERVE,
|
||||
changeOrigin: true,
|
||||
// bypass(req, res, options) {
|
||||
// const proxyUrl = new URL(options.rewrite(req.url) || '', (options.target) as string)?.href || ''
|
||||
// req.headers['x-req-proxyUrl'] = proxyUrl;
|
||||
// res.setHeader("x-res-proxyUrl", proxyUrl)
|
||||
// }
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user