Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window设置代理端口,使用环境变量启动并未生效 #3568

Closed
chenkarl opened this issue Mar 26, 2019 · 2 comments · Fixed by #3569
Closed

window设置代理端口,使用环境变量启动并未生效 #3568

chenkarl opened this issue Mar 26, 2019 · 2 comments · Fixed by #3569

Comments

@chenkarl
Copy link

现在已开启与安装egg-development-proxyagent该插件

命令行执行该命令启动
set http_proxy=http://127.0.0.1:8888;npm run dev
在anyproxy中并没有拦截到请求,使用fillder同样没有拦截到

@atian25
Copy link
Member

atian25 commented Mar 26, 2019

https://github.com/eggjs/egg-development-proxyagent/blob/master/app.js

可以调试下 env 有没有正确传递进来

@atian25
Copy link
Member

atian25 commented Mar 26, 2019

可以不用这个插件了,直接加下 config.local.js 的配置:

// config.local.js
module.exports = () => {
  const config = {};

  // add http_proxy to httpclient
  if (process.env.http_proxy) {
    config.httpclient = {
      request: {
        enableProxy: true,
        rejectUnauthorized: false,
        // proxy: process.env.http_proxy,
      },
    };
  }

  return config;
}

启动时:

# win 的改为 set 或者用 crossenv 这个库
$ http_proxy=http://127.0.0.1:8888 npm run dev

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

Successfully merging a pull request may close this issue.

2 participants