我已经构建了一个 slimPHP REST API。这是我的标题:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Headers: origin, content-type, accept');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT');
header('Access-Control-Max-Age: 86400');
然而,当我尝试跨域 PUT 或 DELETE 请求时,我得到的只是(示例域):
XMLHttpRequest cannot load http://www.example.com/api/x.
Origin http://www.example.com is not allowed by Access-Control-Allow-Origin.
如果 Access-Control-Allow-Origin 设置为 * ,知道为什么会发生这种情况吗?