withRouting( web: __DIR__.'/../routes/web.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware): void { $middleware->alias([ 'admin' => EnsureAdmin::class, 'subscribed' => EnsureSubscribed::class, ]); // Stripe posts to the Cashier webhook with no session and no CSRF // token, so the path is exempted. "stripe" must match // config('cashier.path'), which CASHIER_PATH can change; keep the two // in step if the path is ever customized. $middleware->validateCsrfTokens(except: [ 'stripe/*', ]); }) ->withExceptions(function (Exceptions $exceptions): void { $exceptions->shouldRenderJsonWhen( fn (Request $request) => $request->is('api/*') || $request->expectsJson(), ); })->create();