2017 © Pedro Peláez
 

library laravel-cors

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application

image

abellion/laravel-cors

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application

  • Wednesday, January 25, 2017
  • by abellion
  • Repository
  • 1 Watchers
  • 0 Stars
  • 483 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 4 % Grown

The README.md

Laravel CORS

Add CORS to your Laravel/Lumen app in 2 steps :

Require the package :

composer require abellion/laravel-cors

Add the service provider to your app :

Abellion\Cors\LaravelServiceProvider::class
  • Laravel : In the providers array of the config/app.php file
  • Lumen : In the bootstrap/app.php file using the $app->register(); method.

You're all set ! All origins are allowed by default. If you want to config your own domains, see bellow., (*1)

Configuring allowed origins :

By default all origins are allowed. You can add your own config by modifying the ORIGINS array from the OriginsMiddleware class :, (*2)

use Abellion\Cors\Middleware\OriginsMiddleware;

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

All origins that match one of the regex will be added. In this example localhost and mydomain are allowed., (*3)

Configuring other headers :

use Abellion\Cors\Middleware\OptionsMiddleware;

OptionsMiddleware::$OPTIONS['Access-Control-Allow-Methods'] = "POST, PUT, DELETE, GET, OPTIONS, PATCH, HEAD";

The Versions

25/01 2017

1.0.1

1.0.1.0

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application

  Sources   Download

MIT

by Antoine Bellion

10/10 2016

dev-master

9999999-dev

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application

  Sources   Download

MIT

by Antoine Bellion

10/10 2016

1.0.0

1.0.0.0

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application

  Sources   Download

MIT

by Antoine Bellion

10/10 2016

1.0.2

1.0.2.0

Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application

  Sources   Download

MIT

by Antoine Bellion