32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Illuminate\Foundation\Application;
|
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
use Illuminate\Foundation\Configuration\Middleware;
|
|
use Illuminate\Http\Request;
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|
|
|
return Application::configure(basePath: dirname(__DIR__))
|
|
->withRouting(
|
|
api: __DIR__.'/../routes/api.php',
|
|
commands: __DIR__.'/../routes/console.php',
|
|
health: '/up',
|
|
apiPrefix: 'api/v1',
|
|
)
|
|
->withMiddleware(function (Middleware $middleware): void {
|
|
// API uses token-based auth, no CSRF needed
|
|
})
|
|
->withExceptions(function (Exceptions $exceptions): void {
|
|
// Return JSON for all API exceptions
|
|
$exceptions->render(function (NotFoundHttpException $e, Request $request) {
|
|
if ($request->is('api/*')) {
|
|
return response()->json([
|
|
'success' => false,
|
|
'message' => 'Resource not found',
|
|
], 404);
|
|
}
|
|
});
|
|
})->create();
|