serverless-express icon indicating copy to clipboard operation
serverless-express copied to clipboard

Issue with json being returned as application/octet-stream

Open hc-danieltiziani opened this issue 4 years ago • 1 comments

I have a pretty standard implementation using the following:

import serverlessExpress from '@vendia/serverless-express';
import { app } from '../app/app';

export const handler = serverlessExpress({ app });

and an endpoint that responds the following:

 healthCheck(request: Request, response: Response): Response {
    const apiResponse = new ApiResponse({});

    return response.json(apiResponse);
  }


// apiResponse -> {"data":{},"code":200,"message":"Success"}

It's running over an AWS ALB, but the content-type being returned (wrongly) is application/octet-stream.

Is there any configuration to avoid this issue?

hc-danieltiziani avatar Jul 16 '21 10:07 hc-danieltiziani

Found out why it was returning as octet, just leaving a feedback here if others face the same issue:

When using AWS ALB, the target group should enable multi-headers, as the following:

image

The typings for loggers are not done yet, so it was kinda hard to debug it, if you wish I could send a PR to improve the config/logger for the handler.

The issue can be closed.

dtiziani avatar Jul 16 '21 19:07 dtiziani