php - Access-Control-Allow-Methods 列表中不存在请求方法 PUT
问题描述
我正在使用 CodeIgniter Rest 服务器,我正在发出 PUT 请求。在 chrome 和 firefox 中一切正常,但在 Internet Explorer 中,我不断收到错误消息,提示请求方法 PUT 不在 Access-Control-Allow-Methods 列表中。,我什至添加了响应头以允许不同的方法,以下是其余服务
public function service_put()
{
if (!$this->_allow) return;
$data = $this->_put_args;
if(isset($data))
{
// have my arguments
try{
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST,PUT,GET,DELETE');
header('Access-Control-Allow-Headers: Origin,X-Requested-With,Content-Type, Accept');
$this->response(['done' => TRUE], REST_Controller::HTTP_OK); // (200) HTTP response code
}
catch(Exception $e)
{
$this->response(array('error' => $e->getMessage()), $e->getCode());
}
return;
}
else
{
$this->returnBadRequest();
return;
}
}
解决方案
推荐阅读
- c# - 未调用 Botframework 恢复对话框
- python - 在 TensorFlow 2.0 上实现 Dueling DQN
- python - anaconda subprocess.CalledProcessError:命令返回非零退出状态 1
- typescript - 为什么 IntelliJ 在保存时不编译 TypeScript?
- java - void androidx.constraintlayout.widget.ConstraintLayout.setVisibility(int) - 在空对象引用上
- php - 在 PHP 中使用 foreach 处理慢查询
- ssl - 带有 AWS 的 Arduino (ESP8266):无法设置 SSL 连接
- c# - 如何在 Ortools 中定义约束以设置不同值的限制
- c# - 我在 asp dot net core 中创建控制器但出现错误
- angular - 使用材料数据表(Angular 7)的两个 NG-Container 元素未显示选定行复选框