Files
Jeremy Graham a948db4a3d fix: redirect guests to the Filament login page (#236)
AuthenticateSession logs a user out after a password change. Laravel then
redirects to a route named "login", which the app does not define, so the
next request failed with HTTP 500.
2026-10-06 16:37:18 +11:00

39 lines
1.6 KiB
PHP

<?php
use App\Services\Helpers\ScheduleHelper;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
$trustedProxies = env('TRUSTED_PROXIES', '*');
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withSchedule(function (Schedule $schedule) {
// Register all scheduled jobs.
ScheduleHelper::registerSchedule($schedule);
})
->withMiddleware(function (Middleware $middleware) use ($trustedProxies) {
// Trust the reverse proxy so forwarded headers (notably
// X-Forwarded-Proto) are honoured. Without this, requests behind an
// SSL-terminating proxy are seen as plain HTTP and absolute URLs such
// as the Filament logout form action are generated over http://.
$middleware->trustProxies(
at: $trustedProxies === '*' ? '*' : explode(',', (string) $trustedProxies),
);
// Laravel sends guests to a route named "login", which this app does not have.
// AuthenticateSession logs the user out after a password change, and the next
// request then failed with "Route [login] not defined" (#236).
$middleware->redirectGuestsTo(fn () => route('filament.admin.auth.login'));
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();