Hi there! I started using Tyk recently, and my use cases comprise of a number of rewrite rules. In a nutshell a typical configuration could look as follows:
When this configuration is applied, Tyk redirects requests from /api/v1/resource/ to mockserver-2 and /api/v1/resource/{id}/ to mockserver-1. However when an unmatched request is received, for which a rule could not be found, HTTP 500 error is returned with the following message:
{
"error": "There was a problem proxying the request"
}
Is there an option to make Tyk return HTTP 404 error for unmatched requests?
Yep it’s easy to setup - in the target URL of the api definition, which is going to be what is used as the fallback, use looping (Looping) to internally redirect to a mock response that returns a 404 - or any kind of response you like for that matter!
In the default-api config, which I posted in the first message, I set .proxy.listen_path property to tyk://fallback-api/fallback/. After spinning up Tyk again I ran a few requests against the new instance and received mock responses only. According to the running mockserver logs, Tyk didn’t even try to send requests for the matching rewrite rules. Do I overlook something?
Unfortunately, that didn’t work I still get the response from the mocked api when I make a request against /api/v1/resource/ endpoint. And no log entries appear in my mockserver console.