调试辅助

调试辅助

如果你需要对 HttpClient 的请求进行抓包调试,可以添加以下配置到 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;
}

然后启动你的抓包工具,如 [charles] 或 [fiddler]。

最后通过以下指令启动应用:

$ http_proxy=http://127.0.0.1:8888 npm run dev

然后就可以正常操作了,所有经过 HttpClient 的请求,都可以你的抓包工具中查看到。