Looking at the following function in Illuminate\Foundation\Http\FormRequest , it seems that Laravel handles it correctly.
public function response(array $errors) { if ($this->ajax() || $this->wantsJson()) { return new JsonResponse($errors, 422); } return $this->redirector->to($this->getRedirectUrl()) ->withInput($this->except($this->dontFlash)) ->withErrors($errors, $this->errorBag); }
And according to the wantsJson function in Illuminate\Http\Request below, you should explicitly look for the JSON answer,
public function wantsJson() { $acceptable = $this->getAcceptableContentTypes(); return isset($acceptable[0]) && $acceptable[0] == 'application/json'; }
source share