-
-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
As you can see from the screenshot, canvas alone is taking up more than 90% of the allowed size of Vercel's serverless functions. Would suggest moving to something more lightweight like: https://www.npmjs.com/package/@napi-rs/canvas
Vercel error
My Serverless function
import { NextApiRequest, NextApiResponse } from 'next'
import nextConnect from 'next-connect'
import QRCode from 'easyqrcodejs-nodejs'
const handler = nextConnect().get(async (req: NextApiRequest, res: NextApiResponse) => {
const options = {
width: 400,
height: 400,
text: 'https://example.com',
dotScale: 0.9,
}
const qrcode = new QRCode(options)
const base64Data = (await qrcode.toDataURL()).replace('data:image/png;base64,', '')
const img = Buffer.from(base64Data, 'base64')
res.setHeader('Content-Type', 'image/png')
res.setHeader('Content-Length', img.length)
res.send(img)
})
export default handler
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed