PHPackages                             diego-rlima/laravel-cors - 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. diego-rlima/laravel-cors

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

diego-rlima/laravel-cors
========================

Simple package to add CORS (Cross-Origin Resource Sharing) headers to the Laravel application.

v1.0.1(7y ago)039MITPHPPHP &gt;=7.0.0

Since Oct 23Pushed 7y agoCompare

[ Source](https://github.com/diego-rlima/laravel-cors)[ Packagist](https://packagist.org/packages/diego-rlima/laravel-cors)[ RSS](/packages/diego-rlima-laravel-cors/feed)WikiDiscussions master Synced yesterday

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

diego-rlima/laravel-cors
========================

[](#diego-rlimalaravel-cors)

Simple package to add CORS (Cross-Origin Resource Sharing) headers to the Laravel application.

Requirements
------------

[](#requirements)

This package requires **Laravel 5.5 or later** and **PHP 7.0.0 or later**.

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

[](#installation)

```
$ composer require diego-rlima/laravel-cors
```

Global usage
------------

[](#global-usage)

To allow CORS for all your routes, add the `CorsMiddleware` in the `$middleware` property of `app/Http/Kernel.php` class:

```
protected $middleware = [
    // ...
    \DRL\LaravelCors\CorsMiddleware::class,
];
```

Group middleware
----------------

[](#group-middleware)

You can also allow CORS in a specific middleware group. Just add the `CorsMiddleware` to your group:

```
protected $middlewareGroups = [
    'web' => [
       // ...
    ],

    'api' => [
        // ...
        \DRL\LaravelCors\CorsMiddleware::class,
    ],
];
```

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

[](#configuration)

The defaults are set in `config/cors.php`. Get a copy of this file to your own config directory to modify the settings.

Publish the config using the following command:

```
$ php artisan vendor:publish --provider="DRL\LaravelCors\CorsServiceProvider"
```

> **Note:** If you are explicitly whitelisting headers, you must include `Origin` or requests will fail to be recognized as CORS.

```
return [

    /*
    |----------------------------------------------------------------------
    | Access-Control-Allow-Origin
    |----------------------------------------------------------------------
    |
    | This response header specifies the method or methods allowed when
    | accessing the resource in response to a preflight request.
    |
    */

    'allow_origins' => [
        '*',
    ],

    /*
    |----------------------------------------------------------------------
    | Access-Control-Allow-Methods
    |----------------------------------------------------------------------
    |
    | This response header specifies the method or methods allowed when
    | accessing the resource in response to a preflight request.
    |
    */

    'allow_methods' => [
        'POST',
        'GET',
        'OPTIONS',
        'PATCH',
        'PUT',
        'DELETE',
    ],

    /*
    |----------------------------------------------------------------------
    | Access-Control-Allow-Headers
    |----------------------------------------------------------------------
    |
    | This response header is used in response to a preflight request to
    | indicate which HTTP headers can be used during the actual request.
    |
    */

    'allow_headers' => [
        'Content-Type',
        'X-Auth-Token',
        'Origin',
        'Authorization',
    ],

    /*
    |----------------------------------------------------------------------
    | Access-Control-Expose-Headers
    |----------------------------------------------------------------------
    |
    | This response header indicates which headers can be exposed as part
    | of the response by listing their names.
    |
    */

    'expose_headers' => [
        'Cache-Control',
        'Content-Language',
        'Content-Type',
        'Expires',
        'Last-Modified',
        'Pragma',
    ],

    /*
    |----------------------------------------------------------------------
    | Access-Control-Max-Age
    |----------------------------------------------------------------------
    |
    | This response header indicates how long the results of a preflight
    | request can be cached.
    |
    */

    'max_age' => 60 * 60 * 24,
]
```

The values of `allow_origins`, `allow_methods`, `allow_headers` and `expose_headers` can be set to `array('*')` to accept any value.

License
-------

[](#license)

Released under the MIT License, see [LICENSE](LICENSE).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

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 ~136 days

Total

2

Last Release

2623d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22944913?v=4)[Diego Ribeiro](/maintainers/diego-rlima)[@diego-rlima](https://github.com/diego-rlima)

---

Top Contributors

[![diego-rlima](https://avatars.githubusercontent.com/u/22944913?v=4)](https://github.com/diego-rlima "diego-rlima (2 commits)")

### Embed Badge

![Health badge](/badges/diego-rlima-laravel-cors/health.svg)

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

###  Alternatives

[binaryk/laravel-restify

Laravel REST API helpers

651399.1k](/packages/binaryk-laravel-restify)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[lomkit/laravel-rest-api

A package to build quick and robust rest api for the Laravel framework.

59152.2k](/packages/lomkit-laravel-rest-api)[wirechat/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

5434.7k](/packages/wirechat-wirechat)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[georgeboot/laravel-echo-api-gateway

Use Laravel Echo with API Gateway Websockets

10435.5k](/packages/georgeboot-laravel-echo-api-gateway)

PHPackages © 2026

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