Q: Redirect to login get 404 if debug is true Laravel So this is my web.php
Auth::routes(['verify' => true]);
Route::group(['middleware' => ['auth']], function () {
   Route::get('/add/{prod}', 'LandingPageController@addprod')->name('prod.add');
}

As you can see that route is under the auth middleware, but if I try to go for example to /add/5 without logging in, I get 301 to login if app.debug is true, 404 if it's false
If I dump the error I get Illuminate\Auth\AuthenticationException: Unauthenticated.
Edit
Looks like it caused by Handler, because I've edited a method:
public function render($request, Exception $exception)
{
    if(config('app.debug')) return parent::render($request, $exception);
    else return response()->view('error',array(),404);
}

How can I use a my view for error and not getting this error?

A: A cleaner way to achieve this effect is by modifying Laravel's exception handler.
Modify App\Exceptions\Handler to catch every error and return your shared custom error page.
/**
 * Render an exception into an HTTP response.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Exception  $e
 * @return \Illuminate\Http\Response
 */
public function render($request, Exception $e)
{
    if ($e instanceof NotFoundHttpException) {
        return response()->view('errors.custom', [], 404);
    }

    return parent::render($request, $e);
}

Some customization may be required to fully meet exactly what & how you want data passed to your shared custom view.
