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|callable $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 45
__construct(Application $app)

Create a new middleware instance.

Parameters

Application $app

at line 53
array hosts()

Get the host patterns that should be trusted.

Return Value

array

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

Handle the incoming request.

Parameters

Request $request
Closure $next

Return Value

Response

at line 88
protected array resolveTrustedHostPatterns(Request $request)

Get the trusted host patterns for the current request.

Parameters

Request $request

Return Value

array

at line 111
static void at(array|callable $hosts, bool $subdomains = true)

Specify the hosts that should always be trusted.

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

Parameters

array|callable $hosts
bool $subdomains

Return Value

void

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

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

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 135
protected bool shouldSpecifyTrustedHosts()

Determine if the application should specify trusted hosts.

Return Value

bool

at line 144
protected string|null allSubdomainsOfApplicationUrl()

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

Return Value

string|null

at line 162
static void flushState()

Flush all static state.

Return Value

void