Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Laravel SPA cors

// add a middleware  (php artisan make:middleware Cors)
// add in your kernel (AppHttpMiddlewareCors::class,)
public function handle(Request $request, Closure $next)
{
  return $next($request)->header('Access-Control-Allow-Origin', '*')
  ->header('Access-Control-Allow-Methods','GET, POST, PUT, PATCH, DELETE, OPTIONS')
  ->header('Access-Control-Allow-Headers','Origin, X-Requested-With, Content-Type, Accept, Authorization');
}
Source by github.com #
 
PREVIOUS NEXT
Tagged: #Laravel #SPA #cors
ADD COMMENT
Topic
Name
1+7 =