proxies = explode(',', ($config->trustedProxies ?? '127.0.0.1,REMOTE_ADDR')); } /** * Handle the incoming request and pass it to the next middleware. * If the request is not from a trusted proxy, it returns a response with an error message. * * @param IncomingRequest $request The incoming request. * @param Closure $next The next middleware closure. * @return Response The response returned by the next middleware. */ public function handle(IncomingRequest $request, Closure $next): Response { // Trusted proxies config is set in LoadConfig // $request::setTrustedProxies($this->proxies, $this->headers); if (! $request->isFromTrustedProxy()) { return new Response(json_encode(['error' => 'Not a trusted proxy']), 403); } return $next($request); } }