PHP code example of abellion / laravel-cors

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

    

abellion / laravel-cors example snippets


Abellion\Cors\LaravelServiceProvider::class

use Abellion\Cors\Middleware\OriginsMiddleware;

OriginsMiddleware::$ORIGINS = [
    "/https:\/\/(www\.)?([a-z0-9]+\.)?mydomain\.(com|fr)/",
    "/http(s)?:\/\/(www\.)?localhost(:[0-9]+)?/"
];

use Abellion\Cors\Middleware\OptionsMiddleware;

OptionsMiddleware::$OPTIONS['Access-Control-Allow-Methods'] = "POST, PUT, DELETE, GET, OPTIONS, PATCH, HEAD";
config/app.php
bootstrap/app.php