Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using CORS with AWS SAM

I've created a few Lambda functions that get triggered by API-Gateway events.

Now I want to enable CORS for these endpoints, but it doesn't seem to work. In the last few versions of AWS SAM the CORS functionality was added or updated, but I still can't get it to work.

This is what I tried:

Gobals:
  Api:
    Cors: "'*'"
like image 942
K.. Avatar asked May 08 '18 08:05

K..


1 Answers

You forgot to add the AllowOrigin property.

It needs to look like this:

Globals:
  Api:
    Cors:
      AllowOrigin: "'*'"
like image 193
MaiKaY Avatar answered Sep 28 '22 07:09

MaiKaY