8.5.x Request.php Request::setTrustedHosts(array $hostPatterns)
8.0.x Request.php Request::setTrustedHosts(array $hostPatterns)
8.1.x Request.php Request::setTrustedHosts(array $hostPatterns)
8.2.x Request.php Request::setTrustedHosts(array $hostPatterns)
8.3.x Request.php Request::setTrustedHosts(array $hostPatterns)
8.4.x Request.php Request::setTrustedHosts(array $hostPatterns)
8.6.x Request.php Request::setTrustedHosts(array $hostPatterns)

Sets a list of trusted host patterns.

You should only list the hosts you manage using regexs.

Parameters

array $hostPatterns A list of trusted host patterns:

File

vendor/symfony/http-foundation/Request.php, line 571

Class

Request
Request represents an HTTP request.

Namespace

Symfony\Component\HttpFoundation

Code

public static function setTrustedHosts(array $hostPatterns) {
  self::$trustedHostPatterns = array_map(function ($hostPattern) {
    return sprintf('#%s#i', $hostPattern);
  }, $hostPatterns);

  // we need to reset trusted hosts on trusted host patterns change
  self::$trustedHosts = array();
}