kaz29/cakephp-cors-middleware-plugin
最新稳定版本:1.2.0
Composer 安装命令:
composer require kaz29/cakephp-cors-middleware-plugin
包简介
CorsMiddleware plugin for CakePHP
README 文档
README
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require kaz29/cakephp-cors-middleware-plugin Minimum setup
- Add the following configuration into config/app_local.php.
'App' => [ 'cors' => [ 'allowUrls' => [ 'https://example.com', // your web site urls 'https://app.example.com', ], ], ], OR
When injecting with environment variables, it looks like this...
'App' => [ 'cors' => [ 'allowUrls' => explode(',', env('CORS_ALLOW_URL', '')) ], ], - Add load middleware setting into Application::middleware method.
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue { $middlewareQueue ->add(new CorsMiddleware(Configure::read('App.cors'))) // Add this line // Catch any exceptions in the lower layers, // and make an error page/response ->add(new ErrorHandlerMiddleware(Configure::read('Error'))) Customize settings
'App' => [ 'cors' => [ 'allowUrls' => [ 'https://example.com', // your web site urls 'https://app.example.com', '/^http:\/\/localhost:(\d+)$/', // regular expression support ], 'allowMethods' => [ 'GET', 'POST', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', ], 'allowHeaders' => [ 'Accept-Language', 'content-type', 'Accept', 'Origin', 'Cookie', 'Content-Length', 'Authorization', ], 'exposeHeaders' => [], ], ], Author
Kazuhiro Watanabe - cyo [at] mac.com - https://twitter.com/kaz_29
License
CorsMiddleware plugin for CakePHP is licensed under the MIT License - see the LICENSE file for details
统计信息
- 总下载量: 29.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04