CORS errors specifically when using the new API Gateway UI

0

When creating a new resource/GET method using the new API Gateway UI, I get "Internal Server Error 500" on my preflight requests (CORS is enabled). If I create the resource and method with the old (soon to be replaced UI), there are no errors.

I enabled CloudWatch logs to look into the issue further, and the exact error thrown is: "Execution failed due to configuration error: Unable to parse statusCode. It should be an integer that is defined in the request template."

For now, I will continue to develop using the old UI. What is the solution when using the new UI? I think it's a force switch in a month or less.

  • Hi,

    I am sorry to hear that. Could you describe how you created the API to reproduce the problem?

  • Sure. In the new UI:

    1. Create a resource (I used 'aaa').
    2. Create a GET method.
    3. Configured as follows:
    • Cognito Authorizer (previously configured per docs and working on resources and methods configured in the old UI)
    • A lambda is assigned (any, a hello world is fine)
    • Correct execution role is assigned (previously configured and working)
    • When there are no templates defined (recommended) is checked on incoming request
    • application/json mapping template is present, in VTL
    • Model is assigned in response -Mapping template for output is present in VTL
    1. enable CORS *
    2. deploy API
  • How I am testing:

    1. create a react app and configure it to make api calls using Redux/Thunks
    2. make a doGet and execute

    Result: preflight headers in chrome are identical to working headers from another resource except they are 500 Internal Server Error. If you dig into cloud watch, you'll find it failed with this error: "Execution failed due to configuration error: Unable to parse statusCode. It should be an integer that is defined in the request template."

    Follow above steps, but use the old UI: no errors.

  • Perhaps worth noting that VTL has a lot of exceptions in the scripting windows. I've found if you ignore the warnings and just save it, it works as intended.

APN
asked 9 months ago119 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions