- 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
This commit is contained in:
28
app/Http/Middleware/HandleCors.php
Normal file
28
app/Http/Middleware/HandleCors.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user