如何配置多个接口代理?

为什么我这样写错了?第二个接口代理怎么写?

module.exports = {
  devServer: {
    host: 'localhost',
    port: 8080,
    proxy: {
      '/api': {
        target: 'https://api.it120.cc/zcr',
        changeOrigin: true,
        pathRewrite: {
          '/api': '',
        },
      },
      'https://www.alywlzf.com': {
        target: 'https://www.alywlzf.com',
        changeOrigin: true,
        pathRewrite: {
          'https://www.alywlzf.com': '',
        },
      },
    },
  },
}

image.png

image.png

阅读 1.5k
2 个回答
module.exports = {
  devServer: {
    host: 'localhost',
    port: 8080,
    proxy: {
      '/api/submit.php': {
        target: 'https://www.alywlzf.com',
        changeOrigin: true,
        pathRewrite: {
          '/api': '',
        },
      },
      '/api': {
        target: 'https://api.it120.cc/zcr',
        changeOrigin: true,
        pathRewrite: {
          '/api': '',
        },
      },
    },
  },
}

你访问 A 域名代理 A 域名干啥,直接访问不就得了?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题