I’ve created a reverse proxy through apigee UI, now I’d like to change the target URL based on my org name, so I can have a single proxy to deploy on all orgs. Can someone let me know the steps to do this?
proxy.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
<Description/>
<FaultRules/>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<Flows/>
<HTTPTargetConnection>
<Properties/>
<URL>https://STRING_FOR_REPLACEMENT</URL>
</HTTPTargetConnection>
</TargetEndpoint>
var orgname = context.getVariable("organization.name");
if (orgname == "DEV") {
context.setVariable("systemUrl.myURL", "https://myDev.com/");
}
if (orgname == "STAGE") {
context.setVariable("systemUrl.myURL", "https://myStage.com/");
}
if ((orgname == "LIVE") ) {
context.setVariable("systemUrl.myURL", "https://live.com/");
}
var targetUrl = context.getVariable("target.url");
targetUrl = targetUrl.replace("STRING_FOR_REPLACEMENT", context.getVariable("systemUrl.myURL"));
targetUrl += context.getVariable("proxy.pathsuffix");
var querystring = context.getVariable("request.querystring");
if (querystring && (querystring.length > 0))
{
targetUrl += "?" + querystring;
}
#####NOTE####
I'm using ReversePrxoy not NodeJS proxy