Content-Type header missing from QR Code Worker Example
rolandus opened this issue · 0 comments
rolandus commented
The QR code example located here: https://developers.cloudflare.com/workers/tutorials/build-a-serverless-function seems to be missing the correct Content-Type header.
Here's what the example code looks like:
const generate = async request => {
// ...
return new Response(qr_png, { headers })
}
The paragraph right above it mentions the header that should be there, but the code doesn't match.
By default, the QR code is generated as a PNG. Construct a new instance of Response, passing in the PNG data as the body, and a Content-Type header of image/png: this will allow browsers to properly parse the data coming back from your serverless function, as an image: