mirror of
https://github.com/koel/koel
synced 2024-12-26 04:23:05 +00:00
28 lines
579 B
PHP
28 lines
579 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\UrlGenerator;
|
|
|
|
class ForceHttps
|
|
{
|
|
private $url;
|
|
|
|
public function __construct(UrlGenerator $url)
|
|
{
|
|
$this->url = $url;
|
|
}
|
|
|
|
/** @return mixed */
|
|
public function handle(Request $request, Closure $next)
|
|
{
|
|
if (config('koel.force_https')) {
|
|
$this->url->forceScheme('https');
|
|
$request->setTrustedProxies([$request->getClientIp()], Request::HEADER_X_FORWARDED_ALL);
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|