解决方案: 接口路径和代理名称重复,把代理中的/api 修改成一个不会冲突的名字

 

问题描述:以下两个接口都返回了index.html页面

 

 

接口路径配置

const proxyURL = '/api'

const proxyCmp = '/cmp'

${proxyURL}/market-data/api-keys
${proxyCmp}/apifiny/user/admin/get-message-list
 
代理配置
'/api': {
        target: 'http://www.abc.com',
        changeOrigin: true,
        secure: false
 },
 '/cmp': {
        target: 'http://www.bai.com',
        changeOrigin: true,
        secure: false,
 },

 修改接口路径配置

const proxyURL = '/apiProxy'

${proxyURL}/api/market-data/api-keys
 
修改代理配置
'/apiProxy': {
        target: 'http://www.abc.com',
        changeOrigin: true,
        secure: false,
    
 pathRewrite: {            
      '^/apiProxy': ''
         },
 },
 '/cmp': {
        target: 'http://www.bai.com',
        changeOrigin: true,
        secure: false,
 },

相关文章:

  • 2021-12-08
  • 2022-01-16
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
猜你喜欢
  • 2022-12-23
  • 2023-03-21
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2021-08-14
相关资源
相似解决方案