PHP code example of fastd / cors-provider

1. Go to this page and download the library: Download fastd/cors-provider 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/ */

    

fastd / cors-provider example snippets



return [
    'allow_credentials' => true,
    'origins' => ['*'],
    'methods' => ['GET', 'POST', 'HEAD', 'DELETE', 'PATCH', 'PUT'],
    'headers' => ['*'],
    'exposed_headers' => ['x-custom'],
    'max_age' => null,
];



use FastD\CORSProvider\CorsMiddleware;
use \FastD\Routing\RouteCollection;

route()->middleware(new CorsMiddleware(), function (RouteCollection $router) {
    $router->get('/demo', function () {
        return json([
            'foo' => 'bar',
        ]);
    });
});