34 lines
1.3 KiB
PHP
34 lines
1.3 KiB
PHP
<?php
|
|
|
|
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',
|
|
channels: __DIR__.'/../routes/channels.php',
|
|
health: '/up',
|
|
)
|
|
->withMiddleware(function (Middleware $middleware): void {
|
|
$middleware->alias([
|
|
'admin' => \App\Http\Middleware\EnsureAdmin::class,
|
|
'customer.active' => \App\Http\Middleware\EnsureCustomerActive::class,
|
|
]);
|
|
|
|
// Runs before the whole route stack (incl. `auth`), so /admin on a public
|
|
// hostname 404s instead of redirecting to /login and thereby revealing
|
|
// that an operator console is hosted here. Self-scoped to /admin*.
|
|
$middleware->prependToGroup('web', \App\Http\Middleware\RestrictAdminHost::class);
|
|
|
|
// Stripe posts server-to-server with its own signature (no CSRF token).
|
|
$middleware->validateCsrfTokens(except: ['webhooks/stripe']);
|
|
})
|
|
->withExceptions(function (Exceptions $exceptions): void {
|
|
$exceptions->shouldRenderJsonWhen(
|
|
fn (Request $request) => $request->is('api/*'),
|
|
);
|
|
})->create();
|