如何配置多个接口代理?

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

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.6k
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 域名干啥,直接访问不就得了?

推荐问题