PHPackages                             pedrosancao/laravel-cors-middleware - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. pedrosancao/laravel-cors-middleware

ActiveLibrary[HTTP &amp; Networking](/categories/http)

pedrosancao/laravel-cors-middleware
===================================

CORS middleware for Laravel 5.5 and above

v0.1.1(5y ago)079MITPHPPHP &gt;=7.0

Since Jul 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/pedrosancao/laravel-cors-middleware)[ Packagist](https://packagist.org/packages/pedrosancao/laravel-cors-middleware)[ RSS](/packages/pedrosancao-laravel-cors-middleware/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

CORS middleware for Laravel 5 and 6
===================================

[](#cors-middleware-for-laravel-5-and-6)

CORS middleware for Laravel 5.5 to 5.8 and 6.x.

Laravel 7 comes with [fruitcake/laravel-cors](https://github.com/fruitcake/laravel-cors), so we recommend you go with it.

This package is pretty simple, load configuration from `.env` and also handles [Preflight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request)and custom headers.

Installation
------------

[](#installation)

Preferable use composer

```
composer require pedrosancao/laravel-cors-middleware
```

We use package [Package Discovery](https://laravel.com/docs/5.5/packages#package-discovery)so there's no need to modify any files to enable the middleware, just install and go.

Usage
-----

[](#usage)

Enable middleware for route:

```
Route::get('sample', function () {
    //
})->middleware('cors');
```

Configuration
-------------

[](#configuration)

You may configure allowed domains and headers.

First option is to set on `.env`: allowed domains with `ALLOWED_CORS_DOMAINS` having fallback to `APP_URL` and allowed header with `ALLOWED_CORS_HEADERS`.

To add more than one domain our header separated them with comma.

To have full control of configuration you may copy the config file with:

```
php artisan vendor:publish --tag=cors-middlware
```

Licence
-------

[](#licence)

This library is release under the [MIT licence](LICENCE.md).

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~54 days

Total

2

Last Release

2118d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5047991?v=4)[Pedro Sanção](/maintainers/pedrosancao)[@pedrosancao](https://github.com/pedrosancao)

---

Top Contributors

[![pedrosancao](https://avatars.githubusercontent.com/u/5047991?v=4)](https://github.com/pedrosancao "pedrosancao (8 commits)")

---

Tags

corscors-middlewarelaravel-5laravel-6middlewarelaravelcors

### Embed Badge

![Health badge](/badges/pedrosancao-laravel-cors-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/pedrosancao-laravel-cors-middleware/health.svg)](https://phpackages.com/packages/pedrosancao-laravel-cors-middleware)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
