Enable CORS

This commit is contained in:
Bubka 2021-11-03 23:09:20 +01:00
parent 8318f0f7a6
commit affd4bdf8d
4 changed files with 164 additions and 2 deletions

View File

@ -19,6 +19,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\Fruitcake\Cors\HandleCors::class,
\App\Http\Middleware\SetLanguage::class,
\App\Http\Middleware\ForceJsonResponse::class,
];

View File

@ -13,6 +13,7 @@
"chillerlan/php-qrcode": "3.3",
"doctrine/dbal": "^2.10",
"fideloper/proxy": "^4.4.1",
"fruitcake/laravel-cors": "^2.0",
"khanamiryan/qrcode-detector-decoder": "^1.0.4",
"laravel/framework": "^7.0",
"laravel/passport": "^9.3.2",

137
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "466ca525b24cc1e20c904767747ec472",
"content-hash": "f92af1c598517fac0961ab94f3f347de",
"packages": [
{
"name": "appstract/laravel-options",
@ -68,6 +68,62 @@
],
"time": "2020-04-03T20:54:38+00:00"
},
{
"name": "asm89/stack-cors",
"version": "v2.0.3",
"source": {
"type": "git",
"url": "https://github.com/asm89/stack-cors.git",
"reference": "9cb795bf30988e8c96dd3c40623c48a877bc6714"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/asm89/stack-cors/zipball/9cb795bf30988e8c96dd3c40623c48a877bc6714",
"reference": "9cb795bf30988e8c96dd3c40623c48a877bc6714",
"shasum": ""
},
"require": {
"php": "^7.0|^8.0",
"symfony/http-foundation": "~2.7|~3.0|~4.0|~5.0",
"symfony/http-kernel": "~2.7|~3.0|~4.0|~5.0"
},
"require-dev": {
"phpunit/phpunit": "^6|^7|^8|^9",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"Asm89\\Stack\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alexander",
"email": "iam.asm89@gmail.com"
}
],
"description": "Cross-origin resource sharing library and stack middleware",
"homepage": "https://github.com/asm89/stack-cors",
"keywords": [
"cors",
"stack"
],
"support": {
"issues": "https://github.com/asm89/stack-cors/issues",
"source": "https://github.com/asm89/stack-cors/tree/v2.0.3"
},
"time": "2021-03-11T06:42:03+00:00"
},
{
"name": "beberlei/assert",
"version": "v3.3.0",
@ -1034,6 +1090,83 @@
],
"time": "2021-02-12T00:02:00+00:00"
},
{
"name": "fruitcake/laravel-cors",
"version": "v2.0.4",
"source": {
"type": "git",
"url": "https://github.com/fruitcake/laravel-cors.git",
"reference": "a8ccedc7ca95189ead0e407c43b530dc17791d6a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fruitcake/laravel-cors/zipball/a8ccedc7ca95189ead0e407c43b530dc17791d6a",
"reference": "a8ccedc7ca95189ead0e407c43b530dc17791d6a",
"shasum": ""
},
"require": {
"asm89/stack-cors": "^2.0.1",
"illuminate/contracts": "^6|^7|^8|^9",
"illuminate/support": "^6|^7|^8|^9",
"php": ">=7.2",
"symfony/http-foundation": "^4|^5",
"symfony/http-kernel": "^4.3.4|^5"
},
"require-dev": {
"laravel/framework": "^6|^7|^8",
"orchestra/testbench-dusk": "^4|^5|^6|^7",
"phpunit/phpunit": "^6|^7|^8|^9",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
},
"laravel": {
"providers": [
"Fruitcake\\Cors\\CorsServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Fruitcake\\Cors\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fruitcake",
"homepage": "https://fruitcake.nl"
},
{
"name": "Barry vd. Heuvel",
"email": "barryvdh@gmail.com"
}
],
"description": "Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application",
"keywords": [
"api",
"cors",
"crossdomain",
"laravel"
],
"support": {
"issues": "https://github.com/fruitcake/laravel-cors/issues",
"source": "https://github.com/fruitcake/laravel-cors/tree/v2.0.4"
},
"funding": [
{
"url": "https://github.com/barryvdh",
"type": "github"
}
],
"time": "2021-04-26T11:24:25+00:00"
},
{
"name": "khanamiryan/qrcode-detector-decoder",
"version": "1.0.4",
@ -8280,5 +8413,5 @@
"php": "^7.3"
},
"platform-dev": [],
"plugin-api-version": "1.1.0"
"plugin-api-version": "2.1.0"
}

27
config/cors.php Normal file
View File

@ -0,0 +1,27 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
|--------------------------------------------------------------------------
|
| Here you may configure your settings for cross-origin resource sharing
| or "CORS". This determines what cross-origin operations may execute
| in web browsers. You are free to adjust these settings as needed.
|
| To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
*/
'paths' => ['api/*'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];