diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index a3d8c48..23defd9 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -35,6 +35,7 @@ class Kernel extends HttpKernel \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, + \Barryvdh\Cors\HandleCors::class, ], 'api' => [ diff --git a/composer.json b/composer.json index 5382c12..775619a 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "license": "MIT", "require": { "php": "^7.1.3", + "barryvdh/laravel-cors": "^0.11.3", "fideloper/proxy": "^4.0", "laravel/framework": "5.8.*", "laravel/tinker": "^1.0", diff --git a/composer.lock b/composer.lock index 8e3c40e..d8701a7 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,122 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2dcc4d25d09917a21140b79d2f70193c", + "content-hash": "3c931f67eff4d8d8623ec8cc1f42c0c2", "packages": [ + { + "name": "asm89/stack-cors", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/asm89/stack-cors.git", + "reference": "c163e2b614550aedcf71165db2473d936abbced6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/asm89/stack-cors/zipball/c163e2b614550aedcf71165db2473d936abbced6", + "reference": "c163e2b614550aedcf71165db2473d936abbced6", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/http-foundation": "~2.7|~3.0|~4.0", + "symfony/http-kernel": "~2.7|~3.0|~4.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.0 || ^4.8.10", + "squizlabs/php_codesniffer": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "psr-4": { + "Asm89\\Stack\\": "src/Asm89/Stack/" + } + }, + "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" + ], + "time": "2017-12-20T14:37:45+00:00" + }, + { + "name": "barryvdh/laravel-cors", + "version": "v0.11.3", + "source": { + "type": "git", + "url": "https://github.com/barryvdh/laravel-cors.git", + "reference": "c95ac944f2f20a17949aae6645692dfd3b402bca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/barryvdh/laravel-cors/zipball/c95ac944f2f20a17949aae6645692dfd3b402bca", + "reference": "c95ac944f2f20a17949aae6645692dfd3b402bca", + "shasum": "" + }, + "require": { + "asm89/stack-cors": "^1.2", + "illuminate/support": "5.5.x|5.6.x|5.7.x|5.8.x", + "php": ">=7", + "symfony/http-foundation": "^3.1|^4", + "symfony/http-kernel": "^3.1|^4" + }, + "require-dev": { + "laravel/framework": "^5.5", + "orchestra/testbench": "3.3.x|3.4.x|3.5.x|3.6.x|3.7.x", + "phpunit/phpunit": "^4.8|^5.2|^7.0", + "squizlabs/php_codesniffer": "^2.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.11-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Cors\\ServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Cors\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "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" + ], + "time": "2019-02-26T18:08:30+00:00" + }, { "name": "dnoegel/php-xdg-base-dir", "version": "0.1", diff --git a/config/cors.php b/config/cors.php new file mode 100644 index 0000000..e9b90f8 --- /dev/null +++ b/config/cors.php @@ -0,0 +1,23 @@ + false, + 'allowedOrigins' => ['*'], + 'allowedOriginsPatterns' => [], + 'allowedHeaders' => ['*'], + 'allowedMethods' => ['*'], + 'exposedHeaders' => [], + 'maxAge' => 0, + +];