Apigee handle 307 Temporary Redirect

Hello,
  How do I tell apigee to follow the redirect when it receives a 307 status code.. When I inspect the response I don;t see the redirect url in the header.. But in curl when I set the option  `--location`, curl automatically does the redirect.. How do I achieve the same via apigee ?

Following is what I get when I do `curl` with `--location` flag enabled

curl -i --location -X POST 'https://xxxx/api/v2/login' --header 'Authorization: Basic ======' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'username=ABCDEF'
HTTP/1.1 307 Temporary Redirect
Vary: Origin, Accept, Accept-Encoding
Access-Control-Allow-Credentials: true
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age: 15552000; includeSubDomains
Location: /login
Content-Type: text/plain; charset=utf-8
Content-Length: 41
Date: Sun, 10 Jul 2022 16:29:42 GMT
Connection: keep-alive

HTTP/1.1 200 OK
Vary: Origin, Accept-Encoding
Access-Control-Allow-Credentials: true
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age: 15552000; includeSubDomains
set-cookie: SCICONV9944=58d9b60bae39be6c5ca6eef72497a067; Path=/; Version=1
set-cookie: SCISID9944=A2YgAQuTAAAAAAAAIvAst4NNliI9RfwNTx40hkxzdTX8dSVwZ3FoBBOlLHRxdJ6kLN2cWej982JAs%2FnJ66YZ8%2FowWuAB0uO9O7B4v6AXyX082cpjUgfYHBkf71wx1LyH0VrZd3Ir9B18K%2BE%2Btwtff%2FwJ6HDXiu33sb%2Fu%2FstFBDru1jP%2F4cdpkbpQTZY2Fak9jHxR90bIHmfsdG6IohQqckgb2IOAJVGYReow7SG%2FivEjRM54ldbrl64smimXj3OG4bUyDzyXIeYytvQ8Mr8H5MOLSj7Oci3o5HpJfw3BFJQU%2F9aaxm%2BehcHYpWtUfiLRwv8dIGAwstmHyETxvoILFwModxoHT9yKQnwC%2BbPrSDmJhi5rxK%2BFX2BCrIO05ORWz5%2FHk6DtLac4i%2FbD; Path=/; Version=1; Max-Age=630720000; Expires=Tue, 31-Dec-2029 00:00:00 GMT
Content-Type: application/json; charset=utf-8
Date: Sun, 10 Jul 2022 16:29:43 GMT
Connection: keep-alive
Transfer-Encoding: chunked

Thank you

0 2 497
2 REPLIES 2

NVM I see the `Location` , but how do I get the `base_url` instead of me hardcoding it.. for eg: 

https://xxxx/api/v2/login

this is giving 307 and Location is `login` .. but now it needs to go to the url `https://xxx/login`  I can hardcode the base url but can I get the base url from the response it self ? 

it needs to go to the url `https://xxx/login`  

I'm not clear on what IT is, and which system is "following" the redirect. If you want Apigee to "follow" the 307, then you have to configure the API proxy to do so. There's no configurable "automatic follow" switch in Apigee, that you might find in the fetch API that is available in web browsers . 

I believe the target.url context variable gets the endpoint that Apigee invokes via a target server. Therefore if you receive a 307, then in the response flow for the target you can examine and parse the target.url variable, and grab the scheme and host (and port maybe) and then combine that with the unqualified Location header , and then produce a new URL . If I were doing this I'd do it in a JS callout.