You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在使用Tesla.Adapter.Mint时设置代理凭证?

使用Tesla.Adapter.Mint设置代理凭证的方法

在Tesla.Adapter.Mint中,代理凭证需要直接嵌入到代理元组的第四个参数(选项列表)里,而非像Hackney那样拆分成独立的proxy和proxy_auth配置项。

具体写法示例:

# 配置带凭证代理的Tesla客户端
defmodule MyClient do
  use Tesla

  plug Tesla.Middleware.BaseUrl, "https://api.example.com"
  adapter Tesla.Adapter.Mint, proxy: {:http, "1.2.3.4", 1234, [proxy_auth: {"user", "pass"}]}
end

如果是HTTPS代理,只需将元组第一个元素改为:https:

adapter Tesla.Adapter.Mint, proxy: {:https, "proxy.example.com", 443, [proxy_auth: {"user", "pass"}]}

核心逻辑:Mint的代理格式为{scheme, host, port, options},其中options列表支持proxy_auth参数,值为包含用户名和密码的二元组,以此实现代理身份验证。

内容的提问来源于stack exchange,提问作者Klevison

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 08:25:11