Returns a custom error HTML page when there is an exception

System Information
  • Strapi Version: v4.11.1
  • Operating System: Run strapi inside docker container
  • Database: postgres:14
  • Node Version: v16.11.1

Hi everyone,

Is it possible to create a custom error page when a client browser calls a Not-Found endpoint?

In other words, when someone tries to make a request to a random api/abc endpoint, instead of seeing this (by default)

  "data": null,
  "error": {
    "status": 404,
    "name": "NotFoundError",
    "message": "Not Found",
    "details": {

I want to provide a friendly UI error page. So, is it possible for me to ‘break into’ the lifecycle/middleware?

I’ve tried to have a look here and here but still have no idea how to return an error HTML page…

The same idea applies to uploads/ endpoints as well. Is it possible?

Thank you all in advance.