CORS "SyntaxError: Unexpected end of input at" with fetch API vs PHP

CORS "SyntaxError: Unexpected end of input at" with fetch API vs PHP

/*
* @version: 1.0.0
* @author: Murod Parmonov
* @licence: MIT
*/

class HTTP{


    // post request
    post(url, data){
        return new Promise((resolve, reject) => {
                fetch(url, {
                    method: 'POST',
                    headers: {
                        'Content-type': 'application/json'
                    },
                    body: JSON.stringify(data),
                    'mode': 'no-cors'
                }).
                **then(response => response.json()).then(data => resolve(data)).
                catch(err => reject(err));**
            }
        );
    }



}

const ht = new HTTP;  // http  fetch API class
ht.post('https://correctserverurl.com/', data).then(resData => console.log(resData))    .catch(err => console.log(err));

error I got from the server js代码中标注的双星线是行错误

<?php
header('Access-Control-Allow-Origin: correctdomain.com');
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Headers:  X-Requested-With");

$ping = file_get_contents("php://input");
file_put_contents('ping.json', $ping);
$ping = json_decode($ping, 1);
echo json_encode($data = [
    'status' => 'success'
]);

我包括了整个 class 的 fetch API 即使我认为这是不必要的。 我想我提供了所有需要的细节。 我确保代码在其他服务器上工作,但只有在我的服务器上有问题。 我在这里做错了什么? 我应该怎么做才能解决这个问题?

header('Access-Control-Allow-Headers: X-PINGOTHER, Content-Type'); 实际上,这值得做一点研究。 神奇的线帮助我解决了同样的问题。