注意点

  • 反向代理实例化,不影响别的接口
  • 前端反向代理只是本地开发环境有效 ```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”, }, }) }

  1. ```javascript
  2. server: {
  3. proxy:{
  4. '/api/': {
  5. target: 'https://onramper.tech/',
  6. changeOrigin: true,
  7. rewrite: path => path.replace(/^\/api/, '')
  8. }
  9. }
  10. }