reezy / cors
reezy cors
This package's canonical repository appears to be gone and the package has been frozen as a result.
v0.1.0
2020-10-15 10:31 UTC
Requires
- php: >7.1
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is not auto-updated.
Last update: 2025-04-26 07:58:46 UTC
README
支持PHP-PSR规范的跨域资源共享(cors)中间件。
安装依赖
composer require reezy/cors
配置
<?php
return [
// 是否允许所有的域
'allowed-all-origins' => env('APP_ENV') !== 'prod',
// 允许访问该资源的域
'allowed-origins' => ['http://localhost'],
// 实际请求中允许携带的所有首部字段
'allowed-headers' => ['authorization', 'content-type', 'x-requested-with'],
// 实际请求中允许使用的所有HTTP方法
'allowed-methods' => ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], // ex: GET, POST, PUT, PATCH, DELETE
// 实际的请求是否可以使用credentials
'allowed-credentials' => true,
// 白名单,列出了服务器允许浏览器访问的头
// 六种简单首部不需要指定:Cache-Control, Content-Language, Content-Type, Expires, Last-Modified, Pragma
'exposed-headers' => [ ],
// 预检请求的结果能够被缓存多久,单位秒
'max-age' => 10 * 86400,
];
LICENSE
The Component is open-sourced software licensed under the Apache license.