fix endpoints
This commit is contained in:
+15
-1
@@ -3,6 +3,8 @@
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
@@ -22,7 +24,19 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
'cleanup.scheduler' => \App\Http\Middleware\CleanupScheduler::class,
|
||||
'auth.docs' => \App\Http\Middleware\ApiDocsAuth::class,
|
||||
]);
|
||||
|
||||
$middleware->redirectGuestsTo(function (Request $request) {
|
||||
if ($request->is('api/*') || $request->expectsJson()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return route('login');
|
||||
});
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
$exceptions->render(function (AuthenticationException $e, Request $request) {
|
||||
if ($request->is('api/*') || $request->expectsJson()) {
|
||||
return response()->json(['message' => 'Unauthorized.'], 401);
|
||||
}
|
||||
});
|
||||
})->create();
|
||||
|
||||
Reference in New Issue
Block a user