注意点
- 反向代理实例化,不影响别的接口
- 前端反向代理只是本地开发环境有效
```javascript
/*
- @Date: 2022-04-02 10:06:51
- @LastEditTime: 2022-04-21 15:47:22 */ import Fly from ‘flyio/dist/npm/fly’
var fly=new Fly; fly.interceptors.response.use( (response) => { let res = response.data; return Promise.resolve(res); }, (err) => { return Promise.reject(err); } );
let baseUrl = process.env.NODE_ENV === ‘development’ ? ‘/api’: ‘https://onramper.tech/‘ console.log(process.env.NODE_ENV,baseUrl, “反向代理设置”);
export function channekForm(url, params) { return fly.post(url, params, { baseURL: baseUrl, headers: { authority: “onramper.tech”, authorization: “Basic pk_test_dxzqNk2WS_lI4wRnXTTkilX_R4mbvBczyLOXpWWMM2Y0”, }, }) }
```javascript
server: {
proxy:{
'/api/': {
target: 'https://onramper.tech/',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
}
}
}