Cors.php
720 Bytes
<?php
namespace FootyRoom\Http\Middleware;
use Closure;
use FootyRoom\Config;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class Cors
{
/** @var \FootyRoom\Config */
protected $config;
public function __construct(Config $config)
{
$this->config = $config;
}
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);
$origin = $request->headers->get('Origin');
$domain = $this->config->get('domain');
if ($origin === "https://admin.$domain") {
$response->header('Access-Control-Allow-Origin', "https://admin.$domain");
}
return $response;
}
}