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)076MITPHPPHP &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 yesterday

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

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

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

2065d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c9cc997dca1af30ebb7fe960ba7edbbd6f273eaacbc74b2cb3c0aedfc2b6790?d=identicon)[pedrosancao](/maintainers/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

[matthewbdaly/laravel-etag-middleware

A Laravel middleware for adding ETags to HTTP requests to improve response times

64326.0k2](/packages/matthewbdaly-laravel-etag-middleware)[palanik/lumen-cors

Cross-origin resource sharing (CORS) middleware for Lumen micro-framework.

101237.4k](/packages/palanik-lumen-cors)[tomschlick/request-migrations

HTTP Request Migrations

1844.5k](/packages/tomschlick-request-migrations)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[spinen/laravel-browser-filter

Filters http requests based on browser type.

2146.3k](/packages/spinen-laravel-browser-filter)[laravel-shift/curl-converter

A command line tool to convert curl requests to Laravel HTTP requests.

935.3k](/packages/laravel-shift-curl-converter)

PHPackages © 2026

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