diff --git a/app/Http/Middleware/SetCloudfrontHeaders.php b/app/Http/Middleware/SetCloudfrontHeaders.php new file mode 100644 index 0000000..e74c258 --- /dev/null +++ b/app/Http/Middleware/SetCloudfrontHeaders.php @@ -0,0 +1,31 @@ +hasHeader($this->header)) { + $request->headers->add([ + 'X-Forwarded-Proto' => $request->header($this->header), + 'X-Forwarded-Port' => '443', + ]); + } + + return $next($request); + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index b635438..c9b0955 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -2,6 +2,7 @@ declare(strict_types=1); +use App\Http\Middleware\SetCloudfrontHeaders; use Filament\Facades\Filament; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Application; @@ -19,7 +20,8 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware) { - $middleware->trustProxies('*'); + $middleware->trustProxies('*') + ->append(SetCloudfrontHeaders::class); // Fix for `Route [login] not defined` exception // @see https://github.com/filamentphp/filament/discussions/5226#discussioncomment-10555366