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