Two listen path to be used

I want to use two listen path for the time being.
https://api-gateway.test.com/valueOne/

https://api-gateway.test.com/valueTwo/

So, I want both the listen path point to the same place /valueOne/ and /valueTwo/ ? Is there way I can handle that using regex or dsl?

Thank you for the help in advance.

Edit: Modifying my earlier reply. You can use regex. I think the caveat is to ensure it is a go lang regex. There is a similar thread here

You could also use a Url Rewrite at the root. Similar thread also here

Thank you Olu for the quick response. I have a doubt regarding the regex solution you pointed out. Could you please help? the link is It's possible to use regex in the listen path?

Why test: is present in listen path regex? Could you please help here understanding this. Thanks in advance.
"proxy": { "listen_path": "/v{test:[\d]+}/events/", "strip_listen_path": true }

I am asking internally about this and will return with a proper response. In the meantime, I have experimented with it for a some minutes and I think it’s a group catcher of some kind. I am not too sure but your use case can be achieve with:

  • /{?:valueOne|valueTwo}/ or
  • /value{test:[A-Z]{1}[a-z]+}/
1 Like

Thank you. First option worked well. Much appreciated.

/{?:valueOne|valueTwo} :point_left:

Hi Olu…this regex worked but it is flaky. It fails to respond sometimes and give resource not found error once in while when testing through postman. Is that expected? Please let me know

Just confirmed we have a bug where regex listen paths and strip listen paths return inconsistent results. Tyk would still listen on both paths, however, the issue is with sending the data upstream. A workaround would be to use a url-rewrite. Hope this helps.

Ok got it…could you please help me with the url rewrite for the above configuration.

EDIT: I see I may not have understood the context. So I will drop an answer for the two possibilities I think:

  1. If you are using the original solution with url_rewrite, a listen_path at the root and strip_listen_path set to true.
...
"version_data": {
	"not_versioned": true,
	"default_version": "",
	"versions": {
		"Default": {
			"name": "Default",
			"expires": "",
			"paths": {
				"ignored": [],
				"white_list": [],
				"black_list": []
			},
			"extended_paths": {
				"url_rewrites": [
					{
						"path": "/valueTwo",
						"method": "GET",
						"match_pattern": "/valueTwo",
						"rewrite_to": "https://httpbin.org/anything",
						"triggers": []
					},
					{
						"path": "/valueOne",
						"method": "GET",
						"match_pattern": "/valueOne",
						"rewrite_to": "https://httpbin.org/anything",
						"triggers": []
					}
				]
			}
		}
	}
}
  1. If you are using the regex listen_path with strip_listen_path set to false.
...
"extended_paths": {
	"url_rewrites": [
		{
			"path": "/",
			"method": "GET",
			"match_pattern": "/",
			"rewrite_to": "/",
			"triggers": []
		}
	]
}

Depending on your method and path, the one above should work. You may have to orchestrate one yourself for a more complex scenario