# cors **Repository Path**: ezy/cors ## Basic Information - **Project Name**: cors - **Description**: 支持PHP-PSR规范的跨域资源共享(cors)中间件。 - **Primary Language**: PHP - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-10-15 - **Last Updated**: 2022-05-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Cors Latest Version 支持PHP-PSR规范的跨域资源共享(cors)中间件。 ## 安装依赖 ```bash composer require reezy/cors ``` 配置 ```php 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](LICENSE).