Victor L
Victor L

Reputation: 10220

How to get the correct proxy URL in Apigee?

In my Apigee API Proxy, I need to get the environment URL that is defined in my configuration, so that I can send it as part of the response.

For example: http://myorg-test.apigee.net/pricing

However, when I try to get it using proxy.url, I get an aliased path, like http://rrt18apigee.us-ea.4.apigee.com/pricing

Currently, I'm trying to get it like:

var response = {
    proxyUrl : context.getVariable("proxy.url"),
};

Upvotes: 3

Views: 2614

Answers (1)

Santanu Dey
Santanu Dey

Reputation: 2978

Here is a work around. You can try to get the following variables and create the entire URL

  • Get the request scheme (http or https) from request.Headers.X-Forwarded-Proto (if you are using cloud version) or client.scheme if you are using on-prem
  • Get the host name from request.host
  • Get the entire request path from request.path
  • Entire list of URL query params and list from message.querystring

You can then construct the entire request URL.

( I know this should not be this painful. Please log a bug in case proxy.url is really broken. )

Upvotes: 2

Related Questions