mxi/mxcors

There is no license information available for the latest version (v1.0.1) of this package.

跨域

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

This package is not auto-updated.

Last update: 2024-05-23 05:01:22 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();