Configuring redirects in CUBA to hide the 404 error

Could you please advise how to set up URL redirection in CUBA from http://localhost:8080/ to http://localhost:8080/demo/ ? My goal is to redirect users from the base URL / to /${webContextName}/ so that they do not encounter a 404 - Not Found error page.

Currently, attempting to access the application root without the context, such as http://localhost:8080/ , results in a 404 error. I need users to be automatically redirected to http://localhost:8080/demo/ or a similar URL containing the web context name.

It can be performed by means of Tomcat.
Deploy a separate “ROOT” web application to Tomcat and put instructions there to perform a redirect.

Examples with a JSP page:

Yes, I know how to implement this using Tomcat, but it is not used in my project, so I wanted to solve this issue directly through CUBA itself.

If CUBA application in your case is assembled into one web application “demo”, then it doesn’t have any control over requests to other web applications, outside of its /demo context. So it’s not possible to configure redirect through CUBA in this configuration.