Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions ProcessMaker/Http/Middleware/TrustHosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@ class TrustHosts extends Middleware
{
public function hosts(): array
{
$trustedHost = $this->allSubdomainsOfApplicationUrl();
return [$trustedHost];
$hosts = array_filter([
$this->allSubdomainsOfApplicationUrl(),
]);

$trustedHostsEnv = config('app.trusted_hosts_links', '');
if ($trustedHostsEnv !== '') {
foreach (array_filter(array_map('trim', explode(',', $trustedHostsEnv))) as $host) {
if (str_contains($host, '://')) {
$host = parse_url($host, PHP_URL_HOST) ?: $host;
}
$hosts[] = '^(.+\.)?' . preg_quote($host) . '$';
}
}

return array_values($hosts);
}

public function handle(Request $request, $next)
Expand Down
3 changes: 3 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// The url of our host, will usually be set during installation
'url' => env('APP_URL', 'http://localhost'),

// Comma-separated list of additional trusted hosts (e.g. https://www.google.com)
'trusted_hosts_links' => env('TRUSTED_HOSTS_LINKS', ''),

// The application key to be used for hashing secrets
'key' => env('APP_KEY', 'base64:x80I9vQNxwllSuwBkTwfUa5qkgPTRdwqHCPSz7zHi1U='),

Expand Down
Loading