carpe / scalambda

Toolkit for building/deploying Lambda Functions with SBT
https://carpe.github.io/scalambda/docs/
41 stars 6 forks source link

Failed requests are missing CORS headers on response #32

Closed SwiftEngineer closed 4 years ago

SwiftEngineer commented 4 years ago

Normally, scalambda adds CORS headers for you. However, it looks like when a request fails, CORS headers aren't actually attached.

This can lead to a really difficult to debug error, since, when CORS is denied, you can't actually inspect the response in the browser. So it can lead to a bit of a "wild goose chase".

We should make sure that CORS headers are handled in the case of both a success or a failure. Bonus points for making CORS headers configurable so we can give users a bit more flexibility.

SwiftEngineer commented 4 years ago

To give a head start to anyone who wants to tackle this issue: Here's where the headers come from: https://github.com/carpe/scalambda/blob/develop/core/src/main/scala/io/carpe/scalambda/api/ApiResource.scala#L95