
Answer-first summary for fast verification
Answer: Enable the CORS setting on the API Gateway API endpoint, ensuring that all responses include the Access-Control-Allow-Origin header set to www.example.com.
The CORS policy is configured on the server side to allow cross-origin requests. In this scenario, the CORS error arises because the API Gateway API endpoint is not properly configured to accept requests from www.example.com. The correct option is to enable the CORS setting on the API Gateway API endpoint (Option C) and configure it to include the Access-Control-Allow-Origin header set to www.example.com in its responses. This will allow the website to make cross-origin requests to the API Gateway endpoint without encountering CORS errors.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A company hosts an unauthenticated static website at www.example.com using Amazon S3 and Amazon CloudFront with AWS WAF configured. The website includes a user registration form that, upon submission, calls an Amazon API Gateway endpoint to invoke an AWS Lambda function for processing and forwarding the payload to an external API. During testing, a solutions architect encounters a CORS error and confirms that the CloudFront origin has the Access-Control-Allow-Origin header set to www.example.com. What action should the solutions architect take to resolve the CORS error?
A
Modify the CORS configuration on the S3 bucket by adding CORS rules to the AllowedOrigin element for www.example.com.
B
Activate the CORS setting in AWS WAF and create a web ACL rule where the Access-Control-Allow-Origin header is set to www.example.com.
C
Enable the CORS setting on the API Gateway API endpoint, ensuring that all responses include the Access-Control-Allow-Origin header set to www.example.com.
D
Turn on the CORS setting on the Lambda function, making sure that the function's return code includes the Access-Control-Allow-Origin header set to www.example.com.
No comments yet.