mxi/mxcors

此包的最新版本(v1.0.1)没有可用的许可信息。

跨域

v1.0.1 2021-03-03 13:48 UTC

This package is not auto-updated.

Last update: 2024-09-26 06:42:31 UTC


README

安装和配置

修改项目下的composer.json文件,并添加:

    composer require mxi/mxcors

在/path/to/config/app.php文件中,配置:

    'cors' => array(
        //域名白名单
        'whitelist'   => array(
            //'http://xxx.xx.xxx',
            //'http://xxx.xxx.xxx'
        ),  
        //header头
        'headers' => array(
            'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE, OPTIONS', //支持的请求类型
            'Access-Control-Allow-Credentials' => 'true' //支持cookie
        )
    )

然后执行`composer update`

注册

在/path/to/config/di.php文件中,注册:


$di->cors = new \MxCORS\Inlet();