Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/255.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 他认为';访问控制允许凭据';响应中的头是'';必须是';正确';_Php_Header_Cors_Packets - Fatal编程技术网

Php 他认为';访问控制允许凭据';响应中的头是'';必须是';正确';

Php 他认为';访问控制允许凭据';响应中的头是'';必须是';正确';,php,header,cors,packets,Php,Header,Cors,Packets,在我的应用程序中,我正在构建一个前端网站(基于React构建),并使用PHP作为后端。 我发现了一个错误: jquery.js:9600未能加载:的值 响应中的“访问控制允许凭据”标头为“”,其中 当请求的凭据模式为“包括”时,必须为“真”。 因此,不允许访问源“”。这个 XMLHttpRequest启动的请求的凭据模式为 由withCredentials属性控制 我的PHP标题是: header('Access-Control-Allow-Origin: http://localhost:30

在我的应用程序中,我正在构建一个前端网站(基于React构建),并使用PHP作为后端。 我发现了一个错误:

jquery.js:9600未能加载:的值 响应中的“访问控制允许凭据”标头为“”,其中 当请求的凭据模式为“包括”时,必须为“真”。 因此,不允许访问源“”。这个 XMLHttpRequest启动的请求的凭据模式为 由withCredentials属性控制

我的PHP标题是:

header('Access-Control-Allow-Origin: http://localhost:3000'); 
// header("Access-Control-Allow-Origin: *"); 
header('Content-Type: application/json');
header('Access-Control-Allow-Headers');
header('Access-Contol-Allow-Credentials: true');
我的前端请求如下所示:

$.post(
    {
      async: false,

      type: "POST",
      url:'http://localhost:81',
      data: 
      {
        querytype: "dataRequest"
      },
      crossDomain : true,
      xhrFields: {
          withCredentials: true
      },
      complete: this.completed,
      success: this.reqsuccess,
      error: this.reqError
  });

您还没有为标题“Access Control Allow Headers”指定值。该值应为允许的请求头的逗号分隔列表。标头是可选的,对于跨站点原始请求(COR)不是必需的。请参阅: