33 lines
1.1 KiB
PHP
33 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Http\Middleware\EnsureSubscribed;
|
|
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 {
|
|
$middleware->alias([
|
|
'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();
|