Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #8 from drbyte/patch-1
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
freekmurze authored Jan 10, 2018
2 parents 49e8d46 + 2b708de commit c4a6edb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

This package will add CORS headers to the responses of your Laravel app. Read [this excellent article](https://spring.io/understanding/CORS) on the subject if you want to understand what CORS is all about.

This package support preflight request and is easily configurable to fit your needs.
This package supports preflight requests and is easily configurable to fit your needs.

## Installation

Expand All @@ -18,7 +18,7 @@ You can install the package via composer:
composer require spatie/laravel-cors
```

The package will automatically register it's service provider.
The package will automatically register its service provider.

You must register it as global middleware.

Expand Down Expand Up @@ -86,9 +86,9 @@ return [

## Usage

With the middleware installed your api routes should now get apprioriate cors headers. Preflight requests will be handled as well. If a request comes in that is not allowed, Laravel will return a `403` response.
With the middleware installed your API routes should now get apprioriate CORS headers. Preflight requests will be handled as well. If a request comes in that is not allowed, Laravel will return a `403` response.

The default configuration of this package allows all requests from any origin. You probably want to at least specify some origins. If you want to allow requests to come in in from `https://spatie.be` and `https://laravel.com` add those domains to the config file:
The default configuration of this package allows all requests from any origin (denoted as `'*'`). You probably want to at least specify some origins relevant to your project. If you want to allow requests to come in from `https://spatie.be` and `https://laravel.com` add those domains to the config file:

```php
// config/cors.php
Expand All @@ -104,11 +104,11 @@ The default configuration of this package allows all requests from any origin. Y
...
```

### Creating your own cors profile
### Creating your own CORS profile

Imagine you want to specify allowed origins based on the user that is currently logged in. In that case the `DefaultProfile` which just reads the config file won't cut it. Fortunately it's very easy to write your own cors profile. A valid cors profile is any class that extends `Spatie\Cors\DefaultProfile`.
Imagine you want to specify allowed origins based on the user that is currently logged in. In that case the `DefaultProfile` which just reads the config file won't cut it. Fortunately it's very easy to write your own CORS profile, which is simply a class that extends `Spatie\Cors\DefaultProfile`.

Here's a quick example where it is assumed that you've already added a `allowed_domains` column on your user model:
Here's a quick example where it is assumed that you've already added an `allowed_domains` column on your user model:

```php
namespace App\Services\Cors;
Expand Down

0 comments on commit c4a6edb

Please sign in to comment.