import { APIGatewayEvent } from "aws-lambda";
import fetch from “node-fetch”;
export async function handler(event: APIGatewayEvent) {
try {
const res = await fetch(
“http://fonts.gstatic.com/s/sourcesanspro/v9/ODelI1aHBYDBqgeIAH2zlNzbP97U9sKh0jjxbPbfOKg.ttf”
);
let buffer = await res.buffer();
return {
statusCode: 200,
headers: {
“Content-Type”: “aplication/font-sfnt”
},
body: buffer,
isBase64Encoded: false
};
} catch (error) {
console.log(error);
}
}
I cannot return a stringified buffer because the file is being used by a library that cannot handle stringified data.
This function, of course, works fine in development mode, but does not work in production.
Any ideas?