Skip to main content

DVA-C02 practice question · Troubleshooting and Optimization

A single-page app hosted at https://app.example.com sends a PUT request with a custom X-Request-Id header to an API…

A single-page app hosted at https://app.example.com sends a PUT request with a custom X-Request-Id header to an API Gateway REST API on a different domain. The /orders resource uses a non-proxy Lambda integration. The browser console shows that the preflight OPTIONS request to /orders failed, and the PUT is never sent. Which change will fix this?

  • AAdd an OPTIONS method (mock integration) that returns the Access-Control-Allow-Origin, -Methods, and -Headers response headers
  • BAdd only the Access-Control-Allow-Origin header to the PUT method's integration response for 200 responses
  • CAttach a Lambda authorizer to the OPTIONS method that checks the Origin header against an allow list
  • DAdd a resource policy to the API that allows requests coming from the application's source IP range
Show the answer and explanation

Correct answer: A) Add an OPTIONS method (mock integration) that returns the Access-Control-Allow-Origin, -Methods, and -Headers response headers

A cross-origin PUT with a custom header triggers a preflight. For a non-proxy REST API integration, the resource needs an OPTIONS method that returns the Access-Control-Allow-Origin, -Methods, and -Headers headers.

Why each option is right or wrong

  • A) Correct. A PUT with a custom header is a non-simple request, so the browser sends a preflight first. For non-proxy integrations, API Gateway needs an OPTIONS method, usually with a mock integration, whose 200 response returns Access-Control-Allow-Headers, -Methods, and -Origin.
  • B) Incorrect. CORS-enabled methods do need Access-Control-Allow-Origin, but the preflight goes to OPTIONS, not PUT. Without an OPTIONS response that allows the method and headers, the browser never sends the PUT.
  • C) Incorrect. Browsers don't send credentials or authorization headers on a preflight. An authorizer on OPTIONS would typically reject the preflight and cause the failure rather than fix it.
  • D) Incorrect. Resource policies control who can invoke the API. They don't add the CORS response headers the browser needs to approve the cross-origin request.
Exam domain
Troubleshooting and Optimization · 18% of DVA-C02
Question type
Multiple choice (one answer)

Practise the full DVA-C02 exam

This question is one of a small free sample from the CertRidge DVA-C02 bank. Full practice exams match the real exam's length, time limit and domain weights, explain every option, and Review Mode re-drills the questions you miss.

Original question written from the official exam guide. Not affiliated with AWS; never copied from the real exam.

Worth reading: DVA-C02 cheat sheet, Lambda, DynamoDB, API Gateway, IAM and Cognito, messaging, CI/CD and X-Ray in tables, plus what DVA-C03 changes.