我的应用程序在reCaptcha验证中失败。剩下的唯一错误如屏幕截图1所示。
有没有人能告诉我这仅仅是没有定义xhr.send变量的问题?如果是这样,那么需要在哪里定义呢?对不起-我不是一个开发人员,只是试图建立我的问题的范围,以继续研究。
屏幕截图1:Error from the Network perspective of my Chrome web developer tool
屏幕截图2:Specific error in my angular.js file with reference to xhr.send
下面是我的captcha验证PHP文件的代码:
<?php
$postData = file_get_contents("php://input");
$request = json_decode($postData);
header('Access-Control-Allow-Origin: *');
echo json_encode(isValid($request->captchaResponse));
exit;
function isValid($response) {
try {
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = [
'secret' => 'mykeyishere',
'response' => $response
];
$options = [
'http' => [
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return json_decode($result);
}
catch (Exception $e) {
return null;
}
}
?>根据请求添加头部信息:Header Screenshot
发布于 2020-03-09 04:11:33
据我所知,你的应用程序不能在Apache web服务器上运行,而是使用基于node.js的web服务器(可能是Express.js),静态文件由Ecstatic static file server middleware提供(这是它自我识别的方式:Node.js v8.15.0/ ecstatic server running @ li1252-85.members.linode.com:8080)。由于它是基于Node的web服务器,它没有配置为正确处理PHP脚本,并且所有PHP脚本都以纯文本形式返回。
这个405 HTTP错误的原因是由于这个基于Node的服务器的配置。对于Express.js,您可以定义要服务的请求方法和路由,其他的将被响应为404 (对于允许的请求方法)或405 (对于不允许的请求方法)。
https://stackoverflow.com/questions/60590149
复制相似问题