Serve binary file (jpeg) from serverless function on dev server

I am hosting some function on https://63ce91e8cef8cb26d39da3fd--storied-haupia-59c370.netlify.app/.netlify/functions/files

As you can see the image gets served fine on the deployed site.
However when running netlify functions:serve and I visit the same function path on localhost the image cannot be displayed, because the dev server sends non decoded base64 to my browser.

This is the code for the serverless function

package main

import (
	"context"
	"encoding/base64"
	"fmt"
	"io"
	"log"
	"os"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
)

// snip...

func getFileResponse(file *minio.Object) (*events.APIGatewayProxyResponse, error) {
	buf, err := io.ReadAll(file)
	if err != nil {
		return nil, fmt.Errorf("failed to read file: %s", err)
	}

	encodedBuf := base64.StdEncoding.EncodeToString(buf)

	return &events.APIGatewayProxyResponse{
		StatusCode:      200,
		Body:            encodedBuf,
		IsBase64Encoded: true,
		Headers: map[string]string{
			"Content-Type": "image/jpeg",
		},
	}, nil
}

// snip...

func handler() ...

func main() {
	lambda.Start(handler)
}

Hi @haasal :wave:t6: ,

Welcome to the forums thanks so much for reaching out. I’m not sure if that’s a bug buy you can file a bug on the CLI repository if you’d like our dev team to investigate. Sorry I couldn’t be of more help. Issues · netlify/cli · GitHub