Download binary corrupted

The problem
I’m downloading files such as txt, pdf, excel and zip from those only the text files download fine, the other file types seem to get corrupted after downloading.

Here’s a picture showing the difference between the downloaded file (LEFT) and the file on server (RIGHT)

As you can see in the image, on the right the characters seem to be fine and on the left side there are just squares it seems that after download the file is getting corrupted.

I’m using serverless offline, I haven’t tested in prod because I can’t even make it work in local.

Here’s my code.


const serverless = require('serverless-http');
const express = require('express')
const app = express()

var r_registro = require('./routes/r_registro');
var bodyParser = require('body-parser');
var cors       = require('cors');

app.use(cors({'origin' : '*'}));
app.use(bodyParser.urlencoded({ extended : false }) )

module.exports.handler = serverless(app, {
    request: function(request, event, context) {
        //random code

My controller

function downloadFile(req, res) {
    let path     = require('path');
    let fs       = require('fs');
    let filename = 'my_pdf_file.pdf';
    let filepath = path.resolve(path.join(raiz, filename));
    res.attachment(filepath);//I've tried without this

Note: I have tried a lot of solutions found on the web base64, setHeaders, Buffer, and a lot more.
Is this problem related to: Payload conversion converts data to utf8 · Issue #230 · dherault/serverless-offline · GitHub ?

have you solve this?
I have the same problem =/