8000 如何使用多个 host · Issue #41 · popomore/koa-proxy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.
This repository was archived by the owner on Apr 24, 2019. It is now read-only.
如何使用多个 host #41
Open
Open
@janjon

Description

@janjon

因为我的项目需要调用多个 api, 请问如何配置多个 代理,

development: (config) => ({
    compiler_public_path: `http://${config.server_host}:${config.server_port}/`,
    proxy: {
      enabled: true,
      options: {
        host: 'http://192.168.8.14:1338',
        match: /^\/api\/.*/,
      },
      option2: {
        host: 'http://apiv2.muzhifm.com',
        match: /^\/muzhifmApi\/.*/,
        map: (path) => {
          console.log(path.replace('muzhifmApi', ''));
          return path.replace('/muzhifmApi', '');
        },
      },
    },
  }),

我的代码是这样的,可是第二个不能成功.

if (config.proxy && config.proxy.enabled) {
  app.use(convert(proxy(config.proxy.options)));
  app.use(convert(proxy(config.proxy.option2)));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0