<?php
(我一般放到入口文件里index.php)
// 设置请求头
setHeader();
function setHeader()
{
// 公共响应头
header('Content-Type: Application/json');
// 如果需要跨域,写在这里
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-Requested-With');
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE');
}