# 无法看到第三方网络库发出的任何请求

> axios、fetch、Alamofire、Ktor 或 cURL 的请求没有显示在 Proxyman 中？使用 Automatic Setup、Network Extension，或在库中设置 HTTP 代理。

## 1. 问题 {#1-problem}

* 我能在 Proxyman 中看到其他请求，但看不到我的网站、NodeJS、iOS 或 Android 应用中使用第三方网络库发出的请求，例如 [fetch](https://github.com/github/fetch)、[axios](https://github.com/axios/axios)、[Alamofire](https://github.com/Alamofire/Alamofire)、[Ktor Apache HttpClient](https://ktor.io)、curl 等。

> **备注:** 如果在你的 Mac 上运行的库忽略了代理设置，可以尝试使用 [Network Extension](https://proxyman.com/docs/zh-cn/advanced-features/network-extension)。它无需更改该库的代理设置即可抓取受支持的 HTTP/HTTPS 流量。HTTPS 仍需要信任证书，并启用 [SSL Proxying](https://proxyman.com/docs/zh-cn/basic-features/ssl-proxying)。
>
> Network Extension 目前为 BETA 版，需要 macOS 26 或更高版本以及 Proxyman PRO。

## 2. 全新的自动方案（v4.7.0 或更高版本）✅ {#2-new-automatic-solution-v470-or-later-}

Proxyman v4.7.0 或更高版本可以一键抓取 NodeJS、Python 和 Ruby 脚本的 HTTP/HTTPS 流量。

* 一键完成：无需手动设置 HTTP 代理，也无需手动信任自签名证书。
* 支持 NodeJS、Ruby 和 Python。较新版本还支持 Golang。

### 使用方法 {#how-to-use}

1. 打开 Proxyman → **Setup** 菜单 → **Automatic Setup…**
2. 点击 **Open New Terminal…**
3. 如有需要，请允许 AppleScript 权限请求。
4. 随即会打开一个新的终端窗口。在该窗口中启动你的 Python 后端服务或运行脚本，Proxyman 会抓取其所有流量。
5. 完成 ✅

![Proxyman 的 Automatic Setup 窗口，包含 Terminal App、Web Browsers 和 ElectronJS App 部分](https://proxyman.com/docs/assets/proxyman-automatic-setup-window.jpg)

_通过 Automatic Setup 打开预先配置好的终端_

更多详情请参阅[无法看到 NodeJS、Python 或 Ruby 脚本的 HTTP 流量](https://proxyman.com/docs/zh-cn/troubleshooting/i-could-not-see-any-http-traffic-from-my-nodejs-python-or-ruby-scripts)。

## 3. 旧方法（不推荐 ❌） {#3-old-solution-not-recommended-}

通常，你需要将网络库配置为使用指向 Proxyman 端口（默认为 9090）的 HTTP 代理。

可行的方法如下：

* Fetch：[在 Fetch API 中使用 Fiddler 之类的代理（Stack Overflow）](https://stackoverflow.com/questions/44524236/using-proxy-like-fiddler-with-fetch-api)
* cURL：使用 _--proxy_ 参数。例如：

```
$ curl -v "https://httpbin.org/get?id=123" --proxy localhost:9090
```

延伸阅读：[在 cURL 中使用代理（Stack Overflow）](https://stackoverflow.com/a/9445516/3127477)

* Ktor：[Ktor 客户端代理文档](https://ktor.io/docs/client-proxy.html)
* Alamofire：[在 Alamofire 中使用代理（Stack Overflow）](https://stackoverflow.com/a/42754358/3127477)

### Axios {#axios}

你可以在 Axios 中设置 HTTP 代理，之后其所有流量都会显示在 Proxyman 中。

```javascript
axios.get({
  url: '/v1/user/data',

  // 'proxy' defines the hostname and port of the proxy server
  // Use `false` to disable proxies, ignoring environment variables.
  // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
  // supplies credentials.
  // This will set an `Proxy-Authorization` header, overwriting any existing
  // `Proxy-Authorization` custom headers you have set using `headers`.
  proxy: {
    host: '127.0.0.1',
    port: 9090
  }
});
```

Proxyman 默认监听 9090 端口。要查找你 Mac 的 IP 地址和端口，请参阅 [iOS 设置指南](https://proxyman.com/docs/zh-cn/debug-devices/ios-device#ios-setup-guide)。

## 了解更多 {#learn-more}

* [在 NodeJS 中抓取 Axios 的 HTTP/HTTPS 请求](https://proxyman.com/posts/2023-05-14-Capture-HTTP-HTTPS-Request-From-Axios-NodeJS)
