getHost(); $currentRefererRequest = substr($currentRefererRequest, 7); //Senza http:// $indexDoublePoint = strpos($currentRefererRequest, ':'); $indexFirstSlash = strpos($currentRefererRequest, '/'); $currentRefererRequest = substr($currentRefererRequest, 0, $indexDoublePoint > 0 && $indexDoublePoint < $indexFirstSlash ? $indexDoublePoint : $indexFirstSlash ); if(!in_array($currentRefererRequest, $allowedHost)) { return $response->withStatus(500)->write('Generic error occurred'); } */ $currentHostRequest = $app->request()->getHost(); if(!in_array($currentHostRequest, $allowedHost)) { return $response->withStatus(403)->write('Request arrive from host not allowed'); } return $next($request, $response); } }