feat: 百度统计,处理vite代理后ip查询不可用问题

This commit is contained in:
taoran
2023-11-30 18:53:03 +08:00
parent f3bdf85c93
commit fc8377adde
8 changed files with 52 additions and 27 deletions
+19 -5
View File
@@ -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)
// }
},
}
}
}