定制 aymardkouakou/cakephp-cors-middleware 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

aymardkouakou/cakephp-cors-middleware

最新稳定版本:1.18

Composer 安装命令:

composer require aymardkouakou/cakephp-cors-middleware

包简介

Basic Cors middleware for CakePHP framework.

README 文档

README

Build Status

A CakePHP (3.7+) middleware for activate cors domain in your application. Middleware docs.

Learn more about CORS

Requirements

  • PHP version 7.2 or higher
  • CakePhp 3.7 or higher

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require aymardkouakou/cakephp-cors-middleware

Ensure that debug mode is activated:

// In config/app.php

...

'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),

...

Quick Start

Adding the Middleware:

// In src/Application.php

$middlewareQueue

    ...
    
    ->add(CorsMiddleware::class)
    // OR 
    ->add(new CorsMiddleware())
    
    ...
    

By default the middleware authorize cors for all origins, all methods and all headers. No configuration required for work fine.

Custom configuration

For using custom configuration, you must adding a Cors array in your config/app.php file.

'Cors' => [

    // Authorized options here
    
    'AllowOrigin' => string|array,
    'AllowMethods' => array,
    'AllowHeaders' => array,
    'ExposeHeaders' => array,
    'AllowCredentials' => true|false,
    'Maxge' => int
    
]

Authorized options

Allow all domains

'AllowOrigin' => '*'
// Or
'AllowOrigin' => ['*']

Allow one domain only

'AllowOrigin' => 'localhost:4200'

Allow multiple domains

'AllowOrigin' => [
    'localhost:4200',
    ...
]

统计信息

  • 总下载量: 6.01k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-25