Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh authored May 11, 2020
1 parent 5f5e584 commit 8cc9f7e
Showing 1 changed file with 13 additions and 48 deletions.
61 changes: 13 additions & 48 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,55 +61,20 @@ php artisan vendor:publish --tag="cors"
> **Note:** If you are explicitly whitelisting headers, you must include `Origin` or requests will fail to be recognized as CORS.

```php
<?php

return [

/*
* You can enable CORS for 1 or multiple paths.
* Example: ['api/*']
*/
'paths' => [],

/*
* Matches the request method. `[*]` allows all methods.
*/
'allowed_methods' => ['*'],

/*
* Matches the request origin. `[*]` allows all origins. Wildcards can be used, eg `*.mydomain.com`
*/
'allowed_origins' => ['*'],

/*
* Patterns that can be used with `preg_match` to match the origin.
*/
'allowed_origins_patterns' => [],

/*
* Sets the Access-Control-Allow-Headers response header. `[*]` allows all headers.
*/
'allowed_headers' => ['*'],

/*
* Sets the Access-Control-Expose-Headers response header.
*/
'exposed_headers' => false,

/*
* Sets the Access-Control-Max-Age response header.
*/
'max_age' => false,

/*
* Sets the Access-Control-Allow-Credentials header.
*/
'supports_credentials' => false,
];

```
### Options

| Option | Description | Default value |
|--------------------------|--------------------------------------------------------------------------|---------------|
| paths | You can enable CORS for 1 or multiple paths, eg. `['api/*'] ` | `array()` |
| allowed_origins | Matches the request origin. Wildcards can be used, eg `*.mydomain.com` | `array('*')` |
| allowed_origins_patterns | Matches the request origin with `preg_match`. | `array()` |
| allowed_methods | Matches the request method. | `array('*')` |
| allowed_headers | Sets the Access-Control-Allow-Headers response header. | `array('*')` |
| exposed_headers | Sets the Access-Control-Expose-Headers response header. | `false` |
| max_age | Sets the Access-Control-Max-Age response header. | `0` |
| supports_credentials | Sets the Access-Control-Allow-Credentials header. | `false` |


`allowed_origins`, `allowed_headers` and `allowed_methods` can be set to `['*']` to accept any value.

Expand Down

0 comments on commit 8cc9f7e

Please sign in to comment.