mardi 26 février 2019

Return JSON response instead of 401 Blade file

I am using AuthBasic for APIauthentication in a Laravel project, I have this problem : when the API request authentication is invalid instead of displaying the json response it return the 401 default blade view template.

here is the cod:

app\Http\Middleware\AuthBasic.php

public function handle($request, Closure $next)
{   
    if (Auth::onceBasic()) {
        return response()->json(["message", "Authentication Required!"], 401);
    } else {
        return $next($request);
    }
}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2EzwIUv
via IFTTT

Aucun commentaire:

Enregistrer un commentaire