【发布时间】:2020-01-27 17:22:38
【问题描述】:
我正在尝试在 Laravel 5.5.48 中使用基本身份验证制作 api
当验证成功时('username' and 'password')响应是正确的,但是如果验证不成功(wrong 'username' and 'password' data)显示错误
我没有尝试过,但我无法更改响应中的异常显示 (response()->json(['status'=>'auth failed']))
路由/api.php
Route::post('/index', 'Api\MyController@index')->middleware('auth.basic');
app/Http/Controllers/Api/MyController@index
public function index(Request $request)
{
return response()->json(array('status' => 'success'));
}
【问题讨论】:
标签: php laravel api authentication