class TrustHosts

Constants

private REJECT_ALL_HOST_PATTERN

Properties

protected Application $app

The application instance.

static protected null|array<int, string>|Closure(): array<int, string> $alwaysTrust

The trusted hosts that have been configured to always be trusted.

static protected null|Request): array<int, string> $hostsResolver

The closure used to resolve trusted hosts for the current request.

static protected bool|null $subdomains

Indicates whether subdomains of the application URL should be trusted.

Methods

__construct(Application $app)

Create a new middleware instance.

array
hosts()

Get the host patterns that should be trusted.

Response
handle(Request $request, Closure $next)

Handle the incoming request.

array
resolveTrustedHostPatterns(Request $request)

Get the trusted host patterns for the current request.

static void
at(array|Closure $hosts, bool $subdomains = true)

Specify the hosts that should always be trusted.

static void
resolveHostsUsing(Closure|null $callback)

Register a closure that resolves trusted hosts for the current request.

bool
shouldSpecifyTrustedHosts()

Determine if the application should specify trusted hosts.

string|null
allSubdomainsOfApplicationUrl()

Get a regular expression matching the application URL and all of its subdomains.

static void
flushState()

Flush all static state.

Details

at line 44
__construct(Application $app)

Create a new middleware instance.

Parameters

Application $app

at line 52
array hosts()

Get the host patterns that should be trusted.

Return Value

array

at line 73
Response handle(Request $request, Closure $next)

Handle the incoming request.

Parameters

Request $request
Closure $next

Return Value

Response

at line 87
protected array resolveTrustedHostPatterns(Request $request)

Get the trusted host patterns for the current request.

Parameters

Request $request

Return Value

array

at line 110
static void at(array|Closure $hosts, bool $subdomains = true)

Specify the hosts that should always be trusted.

Boot-only. The list persists in static properties for the worker lifetime and applies to every subsequent request.

Parameters

array|Closure $hosts
bool $subdomains

Return Value

void

at line 124
static void resolveHostsUsing(Closure|null $callback)

Register a closure that resolves trusted hosts for the current request.

Boot-only. The callback persists in static state for the worker lifetime and fully replaces the static trusted host list for every subsequent request.

Parameters

Closure|null $callback

Return Value

void

at line 132
protected bool shouldSpecifyTrustedHosts()

Determine if the application should specify trusted hosts.

Return Value

bool

at line 141
protected string|null allSubdomainsOfApplicationUrl()

Get a regular expression matching the application URL and all of its subdomains.

Return Value

string|null

at line 153
static void flushState()

Flush all static state.

Return Value

void