I'm fairly new to Cloudfront ( AWS in general ), and looking set up a behaviour such that any requests that is for example
test.com/api/*
goes to an existing api that we also own, except it's on a seperate domain, e.g.
staging.test.com/api
Is this an allowed behaviour? I probably will need to allow for this the receiving API in CORS but just looking for how to set this up as a behaviour in Cloudfront.
I have tried using lambda functions along with the route
e.g.
var response = {
statusCode: 302,
statusDescription: 'Found',
headers:
{ "location": { "value": "https://staging.test.com.au/api/" + redirectPath } }
}
return response;
That doesn't seem to be working.
So was just wondering what is the correct way of going about this, I can only find references on using an API gateway instead which isn't what I want.