Call the Create API

This sounds like the CORS headers are not being returned in your Lambda functions?

We’ve moved the steps around but make sure that you have this in your Lambda functions.

Hi @jayair! Thanks for the reply. Yes I think I have those covered. My my files are here if you have time: https://github.com/jeffcordova/serverlesss-stack-api. Do you think it’s a backend issue even if the test in the previous chapters were successful? Or how do I debug this? Thank you!

Hi @jayair, I tried logging my response in the Lambda function. It seems it’s returning the correct headers.

2020-11-16T03:59:07.661Z f69bcc1f-2f21-4793-a37c-f09011fcd66d INFO { statusCode: 200, body: '{"userId":"ap-southeast-1:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","noteId":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","content":"test today","createdAt":1605499147577}', headers: { 'Access-Content-Allow-Origin': '*', 'Access-Content-Allow-Credentials': true }}

So I’m guessing the issue is with my API Gateway? If you have suggestions on how to knock this one down, feel free to suggest. Thank you.

Yeah API Gateway needs to handle the OPTIONS request as well. For that you need this:

Hi Jeff, don’t know whether you solved this issue. I looked at the create function and found that my function wasn’t using the handler-lib which we edit in the CORS Handle CORS in Serverless APIs | Serverless Stack.
I redeployed the backend with the create function using this handler and it returned a 200. :slight_smile:

1 Like