0

我对 Graphileon 的代理功能有一个问题。我们如何将基本身份验证之类的凭据传递给 Graphileon 代理请求命中后端 API

var body = JSON.stringify({
                    url: "http://localhost:8080/api",
                    method: "POST",
                    body: {key1 : "value1"}
                })

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

1 回答 1

0

你可以这样做:

var body = JSON.stringify({
                    url: "http://localhost:8080/api",
                    method: "POST",
                    body: {key1 : "value1"},
                    auth: {
                        user: '...',
                        pass: '...',
                        sendImmediately: false | true
                    }
                })

或者

var body = JSON.stringify({
                    url: "http://<username>:<password>@localhost:8080/api",
                    method: "POST",
                    body: {key1 : "value1"},
           })

或者

var body = JSON.stringify({
                    url: "http://localhost:8080/api",
                    method: "POST",
                    body: {key1 : "value1"},
                    headers: {
                        'Authorization': 'Basic ' + btoa('<username>:<password>')
                    }
    }
于 2021-09-20T17:08:12.923 回答