1 Answer
- Newest
- Most votes
- Most comments
0
Just add amplify preview url in the API Gateway resource on which you need. Filling appropriate values in these fields Access-Control-Allow-Methods Access-Control-Allow-Headers Access-Control-Allow-Origin : amplify preview url
answered a year ago
Relevant content
- Accepted Answerasked 4 months ago
- asked 6 months ago
- asked a year ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
But each preview will have a new url, that way I will have to manually add each preview
ok then you have to programatically handle Access-Control-Allow-Origin with api gateway response integration. Example if your api gateway intergrate with lambda function, then from lambda function you need to set which amplify preview url to be allowed. code snippet in you backend lambda response contain
const response = { headers: { allowOrigin: amplifydomainurl } };
and in your api gateway response integration should map it like this
method.response.header.Access-Control-Allow-Origin: "integration.response.body.headers.allowOrigin"
By this you can control dynamic amplify preview urls to be allowed from backend logic.
Getting this error: "Invalid mapping expression specified: Validation Result: warnings : [], errors : [Operations on header access-control-allow-origin are restricted]"