cloudflare / workers-docs

🌥👷‍♀️ The documentation site for Cloudflare Workers
https://developers.cloudflare.com/workers
106 stars 151 forks source link

Content-Type header missing from QR Code Worker Example #965

Closed rolandus closed 4 years ago

rolandus commented 4 years ago

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: