Authenticate.php 541 B

12345678910111213141516171819
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Illuminate\Auth\Middleware\Authenticate as Middleware;
  4. use Illuminate\Http\Exceptions\HttpResponseException;
  5. use Illuminate\Http\Request;
  6. class Authenticate extends Middleware
  7. {
  8. /**
  9. * Get the path the user should be redirected to when they are not authenticated.
  10. */
  11. protected function redirectTo(Request $request): ?string
  12. {
  13. // throw new HttpResponseException(response()->json(['code' => 401]));
  14. return $request->expectsJson() ? null : route('login');
  15. }
  16. }