feat: implement and use new confg key for trusted hosts (#1797)

This commit is contained in:
MichaIng 2024-07-17 00:07:58 +02:00 committed by GitHub
parent 3f4b887c6a
commit 19e704ccc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 3 deletions

View file

@ -3,6 +3,11 @@ APP_ENV=production
APP_DEBUG=true APP_DEBUG=true
APP_URL=http://localhost:8000 APP_URL=http://localhost:8000
# A comma-separated list of (Koel server) hostnames accepted to access Koel.
# Leave this empty to allow access to Koel with any hostname.
# Example: localhost,192.168.0.1,yourdomain.com
TRUSTED_HOSTS=
# A random 32-char string. You can leave this empty if use php artisan koel:init. # A random 32-char string. You can leave this empty if use php artisan koel:init.
APP_KEY= APP_KEY=

View file

@ -11,8 +11,6 @@ class TrustHosts extends IlluminateTrustHost
*/ */
public function hosts(): array public function hosts(): array
{ {
return [ return config('app.trusted_hosts');
$this->allSubdomainsOfApplicationUrl(),
];
} }
} }

View file

@ -32,6 +32,19 @@ return [
'url' => env('APP_URL', 'http://localhost'), 'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Trusted hosts
|--------------------------------------------------------------------------
|
| An array of (Koel server) hostnames accepted to access Koel.
| An empty array allows access to Koel with any hostname.
| Example: ['localhost', '192.168.0.1', 'yourdomain.com']
|
*/
'trusted_hosts' => explode(',', env('TRUSTED_HOSTS', '')),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Application Timezone | Application Timezone