PHP的CORS问题 - 预检请求

时间:2017-01-02 09:16:15

标签: php angularjs cors

我对PHP有 $http({ url: url, method: "GET", headers: { 'Authorization': 'Bearer zPwDlSp5AKv7MnZRwWyULhavD3WmTFPH', 'Content-Type': 'application/json' }, data: JSON.stringify({'user_id': '17'}) }).then(function(response) { console.log('Success!'); console.log(response.data); }, function(response) { console.log('Failed!'); console.log(response); }) 问题。我的角度中有以下代码:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header("Access-Control-Allow-Headers: Authorization, X-Requested-With, Content-Type, Accept, Origin");
header('Access-Control-Allow-Credentials: true');

跟随后端的php代码:

NumNavController

但是,标题设置正确我得到了: -

  

预检请求错误。

0 个答案:

没有答案