[Troubleshooting] CORS setting was not working when I implemented AWS API Gateway+Lambda Server-less Application

This is record of troubleshooting about CORS setting when I implemented AWS server-less application

It’s a common things using combination of Lambda and API Gateway. If you already know that two services, it’s very simple to implement server-less environment. But if you not, it needs time to search about that, so I decided to record my troubleshooting history.

Simple & Non-simple Request

Do you guys know that cross-origin request is divided 「Simple cross-origin HTTP request」 and 「Non-simple cross-origin HTTP request」?

CORS enable setting is not working in non-simple request.

I said the answer first.

Image for post
Image for post
Enable CORS action in AWS API Gateway

How can I communicate under the cross origin environment?

I know, you don’t want the reason why error occurred. I start to solve this problem.

  1. Serialize your response body.
e.g: How to write response of the Lambda


It’s very fantastic things that we can create server-less service easily using API Gateway and Lambda.

Korean, live in Japan. The programmer. I love to learn something new things. I’m publishing my toy projects using GitHub. Visit https://www.jangwook.net.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store