serverless-components / express

⚡ Take existing Express.js apps and host them easily on cheap, auto-scaling, serverless infrastructure (AWS Lambda and AWS HTTP API).
https://serverless.com/components
Apache License 2.0
375 stars 34 forks source link

How to compress (gzip) responses in express #36

Open rishav394 opened 4 years ago

rishav394 commented 4 years ago

I have used compression in my express application like so:

  const compression = require('compression');
  const app = express();
  app.use(compression());

While running locally all my responses are compressed but when running on serverless using sls deploy or sls dev I get net::ERR_CONTENT_DECODING_FAILED 200 I am assuming that serverless cant perform compression but the headers are set by the compression library and thus this error.

I need to compress my responses. I came across this as well but wasn't able to make it work (Nothing was being compressed).

Here is my serverless.yml

org: rishav394
app: my-app
component: express
name: express-compress

inputs:
  src: ./

Any help is appreciated. Thanks.

eahefnawy commented 3 years ago

I believe we're gonna have to add the minimumCompressionSize input for that to work, just like the framework. Not 100% sure though 🤔