php使用exec函数FFMPEG命令后,跨域请求 header 不起作用

我使用 php exec 函数执行 FFMPEG 命令,我也使用 Javascript 发送请求,它们是跨源请求,但是在 exec 命令之后,当我开始发送下一个跨源请求时,它显示访问 Access to XMLHttpRequest at 'https://www.example.com:550/api/adminapi' from origin 'https://www.example.com:8081' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. 这意味着跨域header在 exec 命令之后的下一个跨域请求中不起作用,下面是代码:

if (isset($_POST['crossorigin'])) {
$crossoriginallow = array();
$crossoriginallow = [
'https://www.example.com:8080', 
'https://www.example.com:8081', 
'https://www.example.com:8082'];
for ($i = 0; $i < sizeof($crossoriginallow); $i++) {
if ($crossoriginallow[$i] == $_POST['crossorigin']) {
  $crossorigin = $_POST['crossorigin'];
  break;
  }
}
header("Access-Control-Allow-Origin:$crossorigin");
header("Access-Control-Allow-Methods:GET, POST, OPTIONS, DELETE");
header("Access-Control-Allow-Headers:DNT,X-Mx-ReqToken,Keep- 
Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache- 
Control,Content-Type, Accept-Language, Origin, Accept-Encoding");
}

exec("ffmpeg -i " . $infilepath . " -c:v mpeg4 -preset veryslow - 
 c:a mp3 -q 0 " . $outfilepath /* . " 2>&1" *//* , $out */);

 $infilepathsep = explode('/', $infilepath);
 $folderpath = '';
 for ($i = 0; $i < sizeof($infilepathsep) - 1; $i++) {
 $folderpath = $folderpath . $infilepathsep[$i];
 $folderpath = $folderpath . '/';
}

 $opendirhandle = opendir($folderpath);
 closedir($opendirhandle);
 $openfilehandle = fopen($infilepath, 'r');
 fclose($openfilehandle);
 unlink(iconv("utf-8", "gbk", $infilepath));
 $result['data'] = $outfilepath;
 $result['msg'] = 'success';
 $jsonresult = json_encode($result);
 echo $jsonresult;
 ob_get_contents();
 ob_end_flush();

这个问题之前没遇到,但重装系统后遇到了,请问是否有人知道其中的原因,谢谢