!(https://hackernoon.com/hn-images/1*2f_ubcCK3g4zbzgfQp_VFA.png)\n\nI’ve recently started working on some small projects that will only use the backend portion of Laravel. One of the first things we bump into is the Authentication Exception that tries to redirect to `/home` or `/login`. That redirection becomes another exception: `InvalidArgumentException: Route [login] is not defined.`. Here is an extreme simple solution for when you only want to work with API Responses.\n\n#### 1- Write a new `BaseRequest`\n\nBy extending Laravel Request object, we can override the methods used by the framework that decides whether to give a redirect response or a JSON response to always prefer JSON.\n\n#### 2- Swap the implementation\n\nInside `public/index.php` we can find where Laravel builds the Request object. Let’s swap `\\Illumiate\\Http\\Request` with our new `BaseRequest` class.\n\n$response = $kernel->handle( \n $request = \\\\App\\\\Http\\\\Requests\\\\BaseRequest::_capture_() \n);\n\n#### 3- Done!\n\nAs simple as this, now any HTTP Request will be treated as it wants `application/json` as the Response. No more Redirect Exceptions.\n\n#### Update\n\n[Alexander Lichter](https://medium.com/@AlexLichter) have a killer one-line middleware to achieve the same result. Check out his solution [here](https://twitter.com/TheAlexLichter/status/969879256271597568).