Files

35 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2026-09-17 23:01:26 -07:00
<?php
2026-10-15 20:59:32 -07:00
use App\Http\Middleware\EnsureAdmin;
2026-10-04 20:34:19 -07:00
use App\Http\Middleware\EnsureSubscribed;
2026-09-17 23:01:26 -07:00
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Http\Request;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
2026-10-04 20:34:19 -07:00
$middleware->alias([
2026-10-15 20:59:32 -07:00
'admin' => EnsureAdmin::class,
2026-10-04 20:34:19 -07:00
'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/*',
]);
2026-09-17 23:01:26 -07:00
})
->withExceptions(function (Exceptions $exceptions): void {
$exceptions->shouldRenderJsonWhen(
fn (Request $request) => $request->is('api/*') || $request->expectsJson(),
);
})->create();