Skip to content

How to compress (gzip) responses in express #36

Open
@rishav394

Description

@rishav394

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions