我使用带有角项目的谷歌recaptcha。 我得到回复
response = grecaptcha.getResponse()
然后进行http调用
url = 'https://www.google.com/recaptcha/api/siteverify?secret=' + secret + '&response=' + response
$http.post(url);
但我收到错误
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
然后我在线搜索我能做什么,并将我的代码更改为:
var headers = {
'Access-Control-Allow-Origin' : '*',
'Access-Control-Allow-Methods' : 'POST, GET, OPTIONS, PUT',
};
$http({
method: 'POST',
headers: headers,
url: url
});
但仍然会出现上述错误。加上我检查了网络,http发送OPTIONS
而不是邮寄。我不知道为什么。