Here’s the setup of my scenario.
Problem:
The client of Service1 stores the cookie for domain .domainxyz.com, hence does not send back the cookie when making the API call to the Apigee proxy on .domainabc.net. This causes the backend call to Service1 to fail.
Can this problem be handled within the Apigee proxy?
Solved! Go to Solution.
This can be handled within the Apigee proxy by rewriting the Set-Cookie header so that it sets the Domain equal to the domain of the Apigee proxy, .domainabc.net. There may be more than one way to modify the Set-Cookie header, but here's one such way using a JavaScript Callout policy.
Using a JavaScript Callout policy within the Target Endpoint PostFlow, try the following.
var setCookie = context.getVariable("response.header.set-cookie"); setCookie = setCookie.replace(/(D|d)omain=.domainxyz.com($|;)/,"Domain=.domainabc.net"); context.setVariable("response.header.set-cookie", setCookie);
This can be handled within the Apigee proxy by rewriting the Set-Cookie header so that it sets the Domain equal to the domain of the Apigee proxy, .domainabc.net. There may be more than one way to modify the Set-Cookie header, but here's one such way using a JavaScript Callout policy.
Using a JavaScript Callout policy within the Target Endpoint PostFlow, try the following.
var setCookie = context.getVariable("response.header.set-cookie"); setCookie = setCookie.replace(/(D|d)omain=.domainxyz.com($|;)/,"Domain=.domainabc.net"); context.setVariable("response.header.set-cookie", setCookie);