Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

如何使用多个 host #41

Open
janjon opened this issue Aug 23, 2016 · 3 comments
Open

如何使用多个 host #41

janjon opened this issue Aug 23, 2016 · 3 comments

Comments

@janjon
Copy link

janjon commented Aug 23, 2016

因为我的项目需要调用多个 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)));
}
@gkaran
Copy link

gkaran commented Oct 7, 2016

I am having the same issue. I need to proxy to two different hosts (one for http and one for websockets) and cannot make this work.

@Stupidism
Copy link

Stupidism commented Feb 8, 2017

I faced the same problem before. We used an individual nginx proxy for frond-end static deployment.
So in develop-env I just send all request to that nginx proxy.
Or you can config your own nginx proxy in your local environment

@wedog
Copy link

wedog commented Jun 23, 2017

这个支持多个host,https://github.com/wedog/koa-nginx

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants