Last updated: 2 minutes read.
In v2.2 the error handler allowed the use a single JSON template to communicate errors to users (a default one is shipped with Tyk, it’s located in
As of v2.3 it is possible to use different templates for specific
HTTP error codes. The
content-type header of the request is also checked, enabling the usage of different template formats, e.g. an XML template.
Please note that it is not possible to override the default message for HTTP 404 errors. These errors indicate that the requested resource could not be found (e.g. the requested URL does not exist).
When a HTTP 500 error occurs, and the request is a JSON request, Tyk will follow this logic:
templates/error_500.jsonexists, this template will be used.
- Otherwise, Tyk will use
When a HTTP 500 error occurs, and the request is a XML request, Tyk will follow this logic:
templates/error_500.xmlexists, this template will be used.
- If no specific template exists for this HTTP code,
templates/error.xmlwill be used.
templates/error.jsonwill be used.
Removing the X-Generator Header
In case of an error, the Tyk Gateway adds the following fixed header and value:
Please note that for
404 Not found errors, Tyk will not return this header from a security perspective. To mitigate this issue, in case you want to better understand your clients and provide you, the manager of the platform, with error information, you can set
true in your
tyk.conf which will then produce error logs showing the resources that were requested and not found.
If you don’t want to return our default X-Generator header (set to tyk.io) in your templates, set
true in your