Lets say we have Dev/Qa environment based API and both environment has separate host name for target end point and there are bunch of host names.
is there any way lets say if i deploy the proxy on ‘test’ environment it should take Dev hostname and when i deploy the proxy on ‘prod’ environment it should take Qa hostname?
you don’t need to overwrite target.url, Just need to use Targetservers in your TargetEndpoint configuration. Since TargetServer is created for a env, based on the env – call will be routed to the appropriate Target,
@Vinay Soni There are a few options here. The simplest would be to create targets servers with the same name in both test and prod, each referring to the corresponding target hostname that you want. You can refer to the apigee documentation for how to create and use target servers in your proxies: http://apigee.com/docs/management/apis/post/organi…
The other option is to do that in your proxies through either a javascript or conditional route rules because EDGE populates the environment.name flow variable for all runtime requests.
For the javascript option,
var env = context.getVariable("environment.name"))
would give you the environment that the proxy request hit and then based on that you can populate the corresponding target.url in the javascript.
For the conditional route rules, it would be something very similar:
Either of these approaches would work, but we recommend going by the target servers approach because then your proxy doesn’t need all this logic or hardcoded URLs, and you can easily update the target server URLs using the management apis as and when you need.
@Vinay Soni just to maintain the community standards and make content easily searchable, can you post this requirement as a new thread instead of combining with the current post. I will answer that once you have made a new post.
By now you may have figured this already out, but there’s a way to leverage Mukunda’s approach and still provide the path. This code should be self-explanatory: