首页 > 解决方案 > 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;
    }


} 

标签: phprestcodeignitercross-domain

解决方案


推荐阅读