0 votes
in AWS by

You have an application that is hosted on an EC2 Instance. This application is part of a custom domain www.demo.com. The application has been changed to make calls to the API gateway.

But the browser is not rendering the responses and Javascript errors are being seen in the developer console.

What must be done to ensure that this issue can be resolved?

1 Answer

0 votes
by

Troubleshooting JavaScript Errors

Question

You have an application that is hosted on an EC2 Instance.

This application is part of a custom domain www.demo.com.

The application has been changed to make calls to the API gateway.

But the browser is not rendering the responses and Javascript errors are being seen in the developer console.

What must be done to ensure that this issue can be resolved?

Answers

Explanations

Click on the arrows to vote for the correct answer

A.  B.  C.  D. 

Answer - D.

This is given in the AWS Documentation.

###########

When your API's resources receive requests from a domain other than the API's own domain, you must enable cross-origin resource sharing (CORS) for selected methods on the resource.

This amounts to having your API respond to the OPTIONS preflight request with at least the following CORS-required response headers:

Access-Control-Allow-Methods.

Access-Control-Allow-Headers.

Access-Control-Allow-Origin.

#############

Option A is invalid because you should not make the architecture change, since this is not the underlying issue.

Option B is invalid because this is the problem with CORS and not the stage itself.

Option C is invalid because using Cognito user pools would add one more unnecessary layer of authentication which is not part of the question requirement.

...