NOTE: It's important to note that this is NOT PRODUCTION READY code and is only used as an example build from. It is EXPECTED that you test and prove this out on your own based on your use-case and understand what the Tyk Gateway has to offer / expected to do.
This is an example using custom go plugins to dynamically set the target_url
for a given Tyk Classic API Definition. This workaround solution revolves around the idea that you can utilize the URL Rewrite middleware as a way to trigger the Gateway to rewrite the target_url
in a custom go plugin satisfying the following code: https://github.com/TykTechnologies/tyk/blob/master/gateway/reverse_proxy.go#L271C6-L271C67.
Basic testing has been done and it should preserve the METHOD
and relative PATH
.
The minimum requirement here is that you need to configure your Tyk Classic API Definition such that the Tyk Gateway is aware of the URL Rewrite and to satisfy the condition: if spec.URLRewriteEnabled && req.Context().Value(ctx.RetainHost) == true