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

Graphileon Proxy功能如何在请求后端API时传递basic auth等身份凭证

要通过Graphileon Proxy传递Basic Auth身份凭证,你只需要在传给代理的请求参数中补充headers字段,把Basic Auth对应的Authorization头配置进去即可,具体操作如下:

实现步骤

  • 首先将你的Basic Auth用户名和密码按照用户名:密码的格式拼接,再编码为Base64字符串
  • 在传给/proxy接口的请求体中新增headers字段,填入Authorization头,值为Basic 你生成的Base64编码字符串

修改后的代码示例

// 替换为实际的用户名和密码
const username = "your_username";
const password = "your_password";
// 生成Basic Auth凭证
const basicAuthCred = "Basic " + btoa(`${username}:${password}`);

var body = JSON.stringify({
    url: "http://localhost:8080/api",
    method: "POST",
    body: {key1 : "value1"},
    // 新增headers字段传入身份凭证
    headers: {
        "Authorization": basicAuthCred
    }
})

$.ajax({
    url: "/proxy",
    method: "POST",
    contentType: "application/json", 
    data: body
})

补充说明

  • 如果你要传递其他类型的身份凭证(比如Bearer Token),也可以按照同样的方式放到headers字段中传递
  • 如果后端API有额外的自定义头要求,也可以统一放在headers对象里,Graphileon Proxy会自动将这些头转发到目标后端接口

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.03 06:54:04