Some checks failed
continuous-integration/drone/push Build is failing
- Complete GGZ Ecademy Laravel backend application - RESTful API for learning products, members, filters - Authentication and authorization system - Database migrations and seeders - Custom CRUD generator commands - Email notification system - Integration with frontend applications
29 lines
592 B
PHP
29 lines
592 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Services\CorsService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class HandleCors
|
|
{
|
|
private CorsService $corsService;
|
|
|
|
public function __construct(CorsService $corsService)
|
|
{
|
|
$this->corsService = $corsService;
|
|
}
|
|
|
|
public function handle(Request $request, \Closure $next)
|
|
{
|
|
/** @var \Illuminate\Http\Response */
|
|
$response = $next($request);
|
|
|
|
if ($this->corsService->isRequestValid($request)) {
|
|
$this->corsService->addHeadersToResponse($response);
|
|
}
|
|
|
|
return $response;
|
|
}
|
|
}
|