Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support minimumCompressionSize input #26

Open
BrandynThornton opened this issue Jul 26, 2020 · 5 comments
Open

Support minimumCompressionSize input #26

BrandynThornton opened this issue Jul 26, 2020 · 5 comments

Comments

@BrandynThornton
Copy link

Hello,

I would like to set cors: true on my httpApi resource, is this possible using the component?

Thanks

@eahefnawy
Copy link
Member

We currently don't have this built in at the API Gateway level, but you could achieve this by returning the right headers in your express app code. Here's an example from the fullstack-app template

https://github.com/serverless-components/fullstack-app/blob/master/api/app.js#L28-L35

@BrandynThornton
Copy link
Author

Thanks, I had the cors npm package installed so I performed a redeploy and it started working. I think I had some manually configured CORS settings on the gateway from testing that must have been interfering.

How about support for compression? I am porting some code from aws-serverless-express and compression seems to be the only part that isn't working anymore.

I've seen some examples in serverless.yml to add the following but I'm guessing the component only supports the input options specified in the documentation.

provider:
name: aws
apiGateway:
minimumCompressionSize: 1024

@eahefnawy
Copy link
Member

@BrandynThornton how do you think that would look like with component? a new input maybe?

@BrandynThornton
Copy link
Author

Yea a new input seems like the most straight-forward approach.

I'm very new to the serverless framework but I think a more powerful solution would be to support configuration options from providers such as https://www.serverless.com/framework/docs/providers/aws/events/apigateway/#compression in a component context. Perhaps it's possible to merge that configuration with the internal component resources' configuration. I understand that would be breaking the clean abstraction that components provide so it probably isn't ideal but it enables a lot of the more complex scenarios. I'm not sure if this even makes sense in a serverless.yml file but this was my first intuition after reading the non-component documentation.

app: express-starter
component: express
name: express-starter
stage: dev

provider:
  name: aws
  apiGateway:
    minimumCompressionSize: 1024

inputs:
  src: ./
  # openApi: true
  roleName: express-starter-lambda-role-us-east-1
  # Environment variables
  env:
    DB_SECRET_ARN: ${env:DBSECRETARN}
    DB_CLUSTER_ARN: ${env:DBCLUSTERARN}

@eahefnawy eahefnawy changed the title ApiGateway CORS Enabled Support minimumCompressionSize input Aug 10, 2020
@eahefnawy
Copy link
Member

Sounds good. I just rephrased this issue. I think we can add this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants