Skip to content

Instantly share code, notes, and snippets.

@Braunson
Created April 12, 2021 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Braunson/e8818d78ceaa3c4720955d8697930ae3 to your computer and use it in GitHub Desktop.
Save Braunson/e8818d78ceaa3c4720955d8697930ae3 to your computer and use it in GitHub Desktop.
Why Laravel does not provide the authenticated user on any error pages

I was curious why my authenticated user didn't persist to my error pages in Laravel.

Only noticing as the layout used for the error pages (header/footer) is the same as the rest of the site and the top right shows the authenticated user, shows a user nav, logout, etc.

Doing a quick Google search brought up some solutions but not necessarily a reason why authenticated users are not available on the error pages.

The reason not to have the authenticated user on the error page:

  • What if the issue is with fetching the authenticated user?

Good point. But what about 404's?

For 404, you can use Route::fallback method, but for other error pages it doesn't make sense.

TIL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment