Closed MitulShah1 closed 2 years ago
I am using Resources owner method , and i just pass username/password in login form and from background using guzzlehttp i pass client id and client secret, Its generate access token i can see in db.
https://prnt.sc/rk15hy
But response coming 500 internal error,
i am using middleware to allow Cors.
here is my CorsMiddleware.php code,
`/**
@return mixed / public function handle($request, Closure $next) { $headers = [ 'Access-Control-Allow-Origin' => '', 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE', 'Access-Control-Allow-Credentials' => 'true', 'Access-Control-Max-Age' => '86400', 'Access-Control-Allow-Headers' => 'Content-Type, Authorization, X-Requested-With' ];
if ($request->isMethod('OPTIONS')) { return response()->json('{"method":"OPTIONS"}', 200, $headers); } $response = $next($request); foreach($headers as $key => $value) { $response->header($key, $value); } return $response;
}`
Now if i comment Cors middleware from bootstrap/app.php
$app->middleware([ App\Http\Middleware\CorsMiddleware::class ]);
its working fine, can you please tell me whats wrong i am doing ?
I am using Resources owner method , and i just pass username/password in login form and from background using guzzlehttp i pass client id and client secret, Its generate access token i can see in db.
https://prnt.sc/rk15hy
But response coming 500 internal error,
i am using middleware to allow Cors.
here is my CorsMiddleware.php code,
`/**
@return mixed / public function handle($request, Closure $next) { $headers = [ 'Access-Control-Allow-Origin' => '', 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE', 'Access-Control-Allow-Credentials' => 'true', 'Access-Control-Max-Age' => '86400', 'Access-Control-Allow-Headers' => 'Content-Type, Authorization, X-Requested-With' ];
}`
Now if i comment Cors middleware from bootstrap/app.php
$app->middleware([ App\Http\Middleware\CorsMiddleware::class ]);
its working fine, can you please tell me whats wrong i am doing ?