DEV Community

Discussion on: Using lambda to get around cors

Collapse
 
andrewbrown profile image
Andrew Brown 🇨🇦 • Edited

On your S3 bucket you can set CORS

If the API call you are making is a public API and not with credentials then it would make sense to call this from your javascript code.

If it is credentialed information you'd want to use a Lambda which you can back by API Gateway.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Looks like I choose wisely, it was the latter. My personal API oauth token is now in environmental variables in both local .env file.

I wondered how much work my lambda should do alter the result in a format I need so compute would do all the work, but instead I went with returning the data as is.

Either way this is my first lambda and a great intro into serverless.