I am having issues trying to get Laravel (5.8) to return a 401 HTTP status code.
Route (api.php)
route::get('test','testController@test');
Controller
public function test(){
return response("error",401)->header('Content-Type','text/plain');
// Also not working.
// header("Content-Type: test/plain", 401);
// print "error";
// exit();
}
The result I am getting is a 200 instead the desired 401. I also test the plain PHP way with header()
and terminate the execution with exit()
, but no luck. Any help will be appreciated.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire