mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
27 lines
651 B
PHP
27 lines
651 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Middleware\Api;
|
|
|
|
use App\Constants\FeatureConstants;
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Config;
|
|
use Laravel\Pennant\Feature;
|
|
|
|
class EnabledOnlyOnLocalhost
|
|
{
|
|
/**
|
|
* @param Closure(Request): mixed $next
|
|
*/
|
|
public function handle(Request $request, Closure $next): mixed
|
|
{
|
|
if (Feature::for(null)->active(FeatureConstants::ENABLED_ONLY_ON_LOCALHOST)) {
|
|
abort_if(! in_array($request->ip(), Config::array('app.local_ips'), true), 403, 'Route only available for localhost');
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|