diff --git a/bootstrap/app.php b/bootstrap/app.php index 3721148..a0c4ca7 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -8,8 +8,6 @@ use Symfony\Component\HttpKernel\Exception\HttpException; use Spatie\Permission\Exceptions\UnauthorizedException; use Inertia\Inertia; -// 信任所有代理(用於反向代理環境) -TrustProxies::at('*'); return Application::configure(basePath: dirname(__DIR__)) ->withRouting( @@ -18,6 +16,9 @@ return Application::configure(basePath: dirname(__DIR__)) health: '/up', ) ->withMiddleware(function (Middleware $middleware): void { + // 信任所有代理(用於反向代理環境) + $middleware->trustProxies(at: '*'); + // Tenancy 必須最先執行,確保資料庫連線在 Session 讀取之前建立 $middleware->web(prepend: [ \App\Http\Middleware\UniversalTenancy::class,