Commit bcc401a4 authored by Viral Solani's avatar Viral Solani

add spatie/cors package

parent 5cc6c83d
...@@ -23,6 +23,7 @@ class Kernel extends HttpKernel ...@@ -23,6 +23,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class, \App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\Spatie\Cors\Cors::class,
]; ];
/** /**
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "bc9d94beb0a4b88c5eaee8a9a2238bea", "content-hash": "cda8a083b7461c2abcd24181fa94e165",
"packages": [ "packages": [
{ {
"name": "arcanedev/log-viewer", "name": "arcanedev/log-viewer",
...@@ -2587,6 +2587,65 @@ ...@@ -2587,6 +2587,65 @@
], ],
"time": "2018-01-20T00:28:24+00:00" "time": "2018-01-20T00:28:24+00:00"
}, },
{
"name": "spatie/laravel-cors",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-cors.git",
"reference": "7e5fa8db4b57e3f8026dd7df9ebdf4ca9086e4e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-cors/zipball/7e5fa8db4b57e3f8026dd7df9ebdf4ca9086e4e9",
"reference": "7e5fa8db4b57e3f8026dd7df9ebdf4ca9086e4e9",
"shasum": ""
},
"require": {
"illuminate/support": "5.5.*|5.6.*",
"php": "^7.0"
},
"require-dev": {
"orchestra/testbench": "3.5.*|3.6.*",
"phpunit/phpunit": "^6.5.4|^7.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\Cors\\CorsServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\Cors\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Send CORS headers in a Laravel or Lumen application",
"homepage": "https://github.com/spatie/laravel-cors",
"keywords": [
"ajax",
"api",
"cors",
"laravel-cors",
"request",
"spatie"
],
"time": "2018-03-09T20:14:04+00:00"
},
{ {
"name": "swiftmailer/swiftmailer", "name": "swiftmailer/swiftmailer",
"version": "v6.0.2", "version": "v6.0.2",
......
<?php
return [
/*
* A cors profile determines which origins, methods, headers are allowed for
* a given requests. The `DefaultProfile` reads its configuration from this
* config file.
*
* You can easily create your own cors profile.
* More info: https://github.com/spatie/laravel-cors/#creating-your-own-cors-profile
*/
'cors_profile' => Spatie\Cors\CorsProfile\DefaultProfile::class,
/*
* This configuration is used by `DefaultProfile`.
*/
'default_profile' => [
'allow_origins' => [
'*',
],
'allow_methods' => [
'POST',
'GET',
'OPTIONS',
'PUT',
'PATCH',
'DELETE',
],
'allow_headers' => [
'Content-Type',
'X-Auth-Token',
'Origin',
'Authorization',
],
'forbidden_response' => [
'message' => 'Forbidden (cors).',
'status' => 403,
],
/*
* Preflight request will respond with value for the max age header.
*/
'max_age' => 60 * 60 * 24,
],
];
<?php <?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
/** /**
* Laravel - A PHP Framework For Web Artisans. * Laravel - A PHP Framework For Web Artisans.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment