PHPackages                             gilsonsouza/lara-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. gilsonsouza/lara-cors

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

gilsonsouza/lara-cors
=====================

Laravel CORS Enable

v1.3.4(9y ago)0690MITPHP

Since Aug 1Pushed 9y agoCompare

[ Source](https://github.com/gilsonsouzah/laracors)[ Packagist](https://packagist.org/packages/gilsonsouza/lara-cors)[ RSS](/packages/gilsonsouza-lara-cors/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (9)Used By (0)

1. Dependência
--------------

[](#1-dependência)

Usando o [composer](https://getcomposer.org/), execute o comando a seguir para instalar automaticamente `composer.json`:

```
composer require gilsonsouza/lara-cors
```

ou manualmente no seu arquivo `composer.json`

```
{
    "require": {
        "composer require gilsonsouza/lara-cors": "^1.0"
    }
}
```

2. Middlewares
--------------

[](#2-middlewares)

Para utilizá-los é necessário registrá-los no seu arquivo app/Http/Kernel.php.

```
 protected $middleware = [
        // other middleware ommited
    	\LaraCors\Cors\CorsMiddleware::class,
 ];
```

3. Provider (opcional)
----------------------

[](#3-provider-opcional)

Selecionar os domínios permitidos no Laraver-Cors em sua aplicação Laravel, é necessário registrar o package no seu arquivo `config/app.php`. Adicione o seguinte código no fim da seção `providers`

```
// file START ommited
    'providers' => [
        // other providers ommited
        \LaraCors\Cors\CorsServiceProvider::class,
    ],
// file END ommited
```

### 3.1 Publicando o arquivo de configuração (somente se tiver feito o passo 3)

[](#31-publicando-o-arquivo-de-configuração-somente-se-tiver-feito-o-passo-3)

Para publicar o arquivo de configuração padrão que acompanham o package, execute o seguinte comando:

```
php artisan vendor:publish  --provider="LaraCors\Cors\CorsServiceProvider"
```

4 Configurações (somente se tiver feito o passo 3, e 3.1)
---------------------------------------------------------

[](#4-configurações-somente-se-tiver-feito-o-passo-3-e-31)

Configure o arquivo com os domínios que dejeja liberar

`config/cors.php`

5 Requisições Ajax
------------------

[](#5-requisições-ajax)

Se estiver usando o guard do laravel e a autenticação via middleware (Authenticate), em suas requisições via ajax, adicione os seguintes parâmetros (nesse caso eu estou utilizando o ajax do jquery, mas utilize o método que preferir, somente lembre de adicionar os parâmetros conforme definidos no seu método)

```
crossDomain : true,
xhrFields: {
    withCredentials: true
}

```

Ex.:

```
$.ajax({
    type: "GET",
    dataType: 'json',
    url: API_ENDPOINT,
    crossDomain : true,
    xhrFields: {
        withCredentials: true
    }
})
.done(function( data ) {
    console.log(data);
});

```

6 Bônus
-------

[](#6-bônus)

Caso seu servidor seje apache, talvez seja necessário adicionar estas linhas abaixo ao .htaccess

```

            Options -MultiViews

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity68

Established project with proven stability

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

Recently: every ~70 days

Total

7

Last Release

3331d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/536990?v=4)[Gilson Souza](/maintainers/gilsonsouza)[@gilsonsouza](https://github.com/gilsonsouza)

---

Top Contributors

[![filipeforattini](https://avatars.githubusercontent.com/u/2805436?v=4)](https://github.com/filipeforattini "filipeforattini (2 commits)")

### Embed Badge

![Health badge](/badges/gilsonsouza-lara-cors/health.svg)

```
[![Health](https://phpackages.com/badges/gilsonsouza-lara-cors/health.svg)](https://phpackages.com/packages/gilsonsouza-lara-cors)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25025.5M80](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87930.4k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.3M84](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69122.6k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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