Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Separate response from target server on setting target.url from Javascript policy

When we are hardcoding our target server url while creating a proxy in 'Backend Service URL' then we are getting 200 OK as a response

2997-capture-1.jpg

But when we are using JS policy to set our target.url(which is same as above) then we are getting 301 in response.

In JS we are setting target server url with

context.setVariable("target.url", targetserverurl);

2998-capture-2.jpg

Does anyone know where the problem can be .... in apigee routing?? or apigee server?? or in our backend web server ?? or something else like JS policy

Solved Solved
1 9 1,954
1 ACCEPTED SOLUTION

@Atanu Mazumdar,

Thanks for sharing the trace files for successful and failure responses. I had a look through them and notice both the requests are identical when they are passed on to the target server, but we get 301 when Javascript is used to modify the target URL.

1. For testing purpose, can you please set "target.header.host" in the Javascript with the IP address of the target server and see if that works ?

2. Please do provide the following information:

a) What version of Private Cloud are you using ?

b) Have you set the target URL in the target endpoint definition, to the same value as that in the Location header ? If not, what is the targetURL in the target endpoint definition?

c) Can you please check in your backend server code under what circumstances do you set the Location Header ?

Regards,

Amar

View solution in original post

9 REPLIES 9