Question
· Aug 7, 2023

404 redirect for Web Application setup

I'm setting up a web application as CSP/ZEN to host a React SPA.  SPA's typically need to use a fallback page to deal with server requests based on the browser route, unless you use hash routing in the browser code.  Our requirements prevent us from using hash routing, so we need to deal with 404's - redirecting/fallback them to index.html - a very common practice.  I 'think' IRIS uses Apache under the hood, so I tried adding a .htaccess in the applications root directory - which did not work.  I found that CSP has an Error class, https://docs.intersystems.com/irislatest/csp/documatic/%25CSP.Documatic...., and think this is the way to deal this it - but I can't figure out how to get a csp 'page' working with Error.  So, I have two questions; Is using an Error page the right/only approach?  And - I need a code example to see how the implementation works - is there a code example for an Error page?

Product version: IRIS 2022.2
Discussion (2)4
Log in or sign up to continue

Hello, Geoff! 

You seem like a deep researcher already so you have probably found this documentation already but I believe you are on the right track! You will probably need to create a custom subclass that extends the %CSP.Error class! 

You can take a look here if you are looking to generate custom errors. I am not able to offer a code example as so far for us the default error pages have been suffice but maybe this can be a leaping point if you haven't found one yet! 
 

HANDLEING ERRORS: 
https://docs.intersystems.com/iris20222/csp/docbook/DocBook.UI.Page.cls?...

CSP ERROR CODES:
https://docs.intersystems.com/iris20222/csp/docbook/DocBook.UI.Page.cls?...