svrjs-nextjs-website/pages/docs/config/custom-error.md
Dorian Niemiec 8109a52fe6
Some checks failed
Deploy Next.js application / deploy (push) Failing after 10m8s
style: change the spelling of a JavaScript runtime from "Node.JS" to "Node.js"
2025-01-07 16:27:52 +01:00

1.1 KiB

title
Custom error pages

Custom error pages

You can configure SVR.JS to serve custom error pages by adding .<errorcode> (SVR.JS 3.0.0 or newer) or <errorcode>.html pages. For the 404 error, you can specify it by changing the page404 property in config.json. From SVR.JS 3.8.0 onwards, you can use errorPages property in config.json to specify path to each custom error page.

When designing custom error pages, you can make use of the following placeholders or templates:

  • {errorMessage} - Displays the error code along with its short description.
  • {errorDesc} - Displays a longer description of the server error.
  • {stack} - Displays the error stack, which is equivalent to the Error.stack property in JavaScript.
  • {path} - Shows the path of the page that caused the error.
  • {server} - Displays the server version string along with the hostname. For example, "SVR.JS/3.9.6 (Linux; Node.js/v12.22.12) on 127.0.0.1:8080" or simply "SVR.JS on svrjs.org".
  • {contact} - Displays the contact information of the server administrator, which can be set using the serverAdministratorEmail property in config.json.