Support the ongoing development of Laravel.io →
Authentication Requests
Last updated 2 years ago.
0

Have you looked into ApiGuard https://github.com/chrisbjr/api-guard). It encapsulates a lot of this token passing. You'll need to remove csrf middleware and replace with a custom Cors middleware:

<?php namespace App\Http\Middleware;

use Closure;

use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Http\Response;

class Cors implements Middleware {

	 /**
	  * Handle an incoming request.
	  *
	  * @param \Illuminate\Http\Request $request
	  * @param \Closure $next
	  * @return mixed
	  */
	 public function handle($request, Closure $next)
	 {
		  return $next($request)
		  		->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')
		        ->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With, X-Authorization, Access-Control-Allow-Origin')
		        ->header('Access-Control-Allow-Credentials', 'true');
	 }
}
Last updated 9 years ago.
0

Thanks. I'll try to work with this api-guard.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

dukejib dukejib Joined 14 May 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.