0
我正在使用角度js。 我有一個表單,我要求用戶輸入URL基本身份驗證詳細信息,即HTTP POST的用戶名和密碼(如PostMan)
我需要檢查憑據是否有效。
我想出了下面的代碼:
$http({method: 'POST', url: $scope.serviceConfig.url, headers: {
'Authorization': 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='}
})
.success(function(res)
{
console.log(res);
})
.error(function(res)
{
console.log(res);
});
我得到以下錯誤:
cannot load https://posttestserver.com/post.php . Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.
- 是放驗證的base64頭內正確的方式?
- 這是服務器的問題還是我做錯了什麼?
- 是否有任何其他方式來測試憑據?
- 有沒有其他的服務器可以測試Auth?我發現https://httpbin.org/但它只支持HTTP GET
你的意思是http://requestb.in對不對?如果是,請編輯。我試着編輯你的,但改變需要至少6個字符 –
你能告訴我這是什麼輸出? –
啊,對不起。它確實是requestb.in。該輸出來自一個名爲「HEAD」的小工具,它發出針對給定URL的「HEAD」請求。 'curl -I'應該達到同樣的效果。 – DaSourcerer