0

I have a django backend and a angular/ui-router frontend. I would like to handle 404 errors (and 400, 403 and 500) on the frontend side. Meaning:

  1. A client send a bad url (page not found)
  2. I catch the exception with a custom error handler on the backend side
  3. Return the 404
  4. Magic!
  5. The frontend redirects to something like www.example.com/#/error404

I could just return a django.shortcut.redirect from the backend side but I read here that crawlers from search engines do not like when you do not return a 404 error code on unknown page. With a redirect I'd be returning a 302...

Or is it just wrong to manage error pages on the client side ? This would be a shame because everything is managed by the frontend (header, footer, etc) so the 404 page would not be following the standard page layout.

Community
  • 1
  • 1
Luke Skywalker
  • 1,464
  • 3
  • 17
  • 35

1 Answers1

0

Check out interceptors here, https://docs.angularjs.org/api/ng/service/$http

Once you set that up, you should be able to redirect to a page according to the error you process.

z.a.
  • 2,549
  • 3
  • 12
  • 16