Two service definition with same listen_path

With REST API one can put into Tyk OSS two different service definitions (with different api_id), but same listen path (proxy.listen_path) E.i: /myservice/…

Which service is then invoked on request to /myservice/?

This depends on what API definition is loaded first into the gateway. Via a REST API I would assume the first/earliest one is the one that is called. On the other hand, loading the APIs from the source file or during startup could result in random behavior since JSON is unordered.

We have a way of mitigating this issue by appending the api_id to the listen_path with a hyphen - as the separator. This way the listen paths can remain unique as much as possible. You can check this yourself by running the Gateway API Definition REST APIs and inspect the listen paths.

A few things are checked before the gateway appends the api_id

  • domain
  • listen_port
  • listen_path

as each of these point to a different route

If you had Hybrid Gateways or MDCB setup, then the check above would not run especially if the sharded tags are completely separate.