mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-25 00:04:33 +02:00
33 lines
609 B
PHP
33 lines
609 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* Class GraphqlLocalhost.
|
|
*/
|
|
class GraphqlLocalhost
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param Request $request
|
|
* @param Closure(Request): mixed $next
|
|
* @return mixed
|
|
*/
|
|
public function handle(Request $request, Closure $next): mixed
|
|
{
|
|
$ip = $request->ip();
|
|
|
|
if ($ip !== '127.0.0.1' && app()->isProduction()) {
|
|
abort(403, "GraphQL is only enabled for localhost");
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|