title: laravel automatically make requests to /api/... XMLHttpRequest
body: <p>I need to send an XMLHttpRequest header with all my requests in order to get a json response</p>
  
  <p>Is it possbile to have this as the default behavior for all api routes?</p>
  
  <p>EDIT:</p>
  
  <p>laravel automatically redirects to the home route when a request fails (e.g. request validation error).</p>
  
  <p>However, when I define the <code>X-Requested-With: XMLHttpRequest</code> header I receive a json response telling me what went wrong. </p>
  
  <p>Since all my endpoints under <code>/api</code> are json specific I would like to default to this behavior without having to define the header.</p>