4071f5d4 by Jeff Balicki

d

1 parent d74885a4
...@@ -49,5 +49,6 @@ class Kernel extends HttpKernel ...@@ -49,5 +49,6 @@ class Kernel extends HttpKernel
49 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class, 49 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class,
50 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 50 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
51 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 51 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
52 'cors' => \App\Http\Middleware\Cors::class,
52 ]; 53 ];
53 } 54 }
......
1 <?php
2 namespace App\Http\Middleware;
3
4 use Closure;
5
6 class Cors
7 {
8
9 /**
10 * Handle an incoming request.
11 *
12 * @param \Illuminate\Http\Request $request
13 * @param \Closure $next
14 *
15 * @return mixed
16 */
17 public function handle($request, Closure $next)
18 {
19 return $next($request)
20 ->header('Access-Control-Allow-Origin', $_SERVER['HTTP_ORIGIN'])
21 // Depending of your application you can't use '*'
22 // Some security CORS concerns
23 //->header('Access-Control-Allow-Origin', '*')
24 ->header('Access-Control-Allow-Methods', 'POST, OPTIONS')
25 ->header('Access-Control-Allow-Credentials', 'true')
26 ->header('Access-Control-Max-Age', '10000')
27 ->header('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-Requested-With');
28 }
29 }
...\ No newline at end of file ...\ No newline at end of file