PHP code example of aymardkouakou / cakephp-cors-middleware

1. Go to this page and download the library: Download aymardkouakou/cakephp-cors-middleware library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aymardkouakou / cakephp-cors-middleware example snippets


// In config/app.php

...

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

...

// In src/Application.php

$middlewareQueue

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

'Cors' => [

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

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

'AllowOrigin' => 'localhost:4200'

'AllowOrigin' => [
    'localhost:4200',
    ...
]
`config/app.php