feat: 完成对接接口
This commit is contained in:
@@ -25,13 +25,23 @@ export default defineConfig((cnf) => {
|
||||
},
|
||||
|
||||
server: {
|
||||
port: 17001,
|
||||
open: true,
|
||||
proxy: {
|
||||
// 代理所有以 /prod-api 开头的请求
|
||||
"/prod-api": {
|
||||
target: "https://ccnetcore.com", // 接口域名
|
||||
changeOrigin: true, // 改变源
|
||||
secure: false, // 如果目标服务器使用 HTTPS 且证书无效,需要设置为 false
|
||||
},
|
||||
[env.VITE_WEB_BASE_API]: {
|
||||
target: env.VITE_API_URL,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(`${[env.VITE_WEB_BASE_API]}`, ""),
|
||||
|
||||
//查看真实代理url
|
||||
bypass(req, res, options) {
|
||||
//@ts-ignore
|
||||
const proxyUrl = new URL(options.rewrite(req.url) || '',(options.target)as string)?.href || '';
|
||||
console.log(proxyUrl);
|
||||
req.headers['x-req-proxyUrl'] = proxyUrl
|
||||
res.setHeader('x-res-proxyUrl',proxyUrl)
|
||||
},
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user