In production I would like to display nice designed error pages, which does not expose any error message to the end user.
However in QA and development I want to continue using the Enonic XP red error page (which contains the error message and stacktrace)
The host in a request can be faked by for instance using /etc/hosts, which I’m doing to have multiple “virtual” hosts on my development laptop.
So instead if want to check use the environment name, cluster name or ip of server instead to determine which error page to show.
I guess I could add some environment name to the site config, but there might be other uses for environment name, cluster name or ip of server in the future. Perhaps when logging stuff.
So is there any way to get environment name, cluster name or ip of server?
One way to do it with JS (maybe not the best one) is to get the system info from the /status/jvm.properties URL. And set the environment variables you need in your startup script. http://localhost:8080/status/jvm.properties
You can use lib-cache so you only need to make the http request once.
It has been needed in several situations in my experience. I have some colleagues that really need this aswell. So far a manual config file has been the solution, but XP should “know” this, we configure the vhost after all, and it would be nice if it was exposed to the developer instead of resorting to hacky solutions.
Do you all need this in http context? If so, as @rymsha says, all info is available in the context object. If you need something else, like clusters or internal host(s) it is currently not easily accessible.