aem-guides-wknd-events icon indicating copy to clipboard operation
aem-guides-wknd-events copied to clipboard

[React] How do we handle 404 error AEM SPA editor?

Open khus29 opened this issue 5 years ago • 2 comments

Local Environment Before filing an issue, verify that the prerequisite tools/software are installed:

  • AEM 6.5 + SP2
  • Java 1.8
  • Apache Maven (3.3.9 or newer)
  • Node.js v10+
  • npm 6+

Describe the issue If user hit any route which does not exists, 404 error, then how do we handle it? What is the standard way to handle it - at AEM end or at react end?

khus29 avatar Feb 04 '20 06:02 khus29

Hi,

are there any recommendations or documentation around this? ACS commons error handler doesnt work with this

viveksachdeva avatar Mar 02 '20 12:03 viveksachdeva

I got it to work using ACS Error handler with some modification in 404.jsp... The issue is that error handler returns path of 404 page as <404page>.html irrespective of the whether originating request is from HTML, or JSON.. In case of SPA, any junk url gets internally redirected to 404.html which calls its model.json for data which again is a junk URL and gets redirected to 404.html instead of 404.model.json,. We want 404.model.json to be a normal request returing JSON data.. Doing this made 404 page render perfectly..

Hope this helps :)

viveksachdeva avatar Mar 02 '20 14:03 viveksachdeva