cloudflare / miniflare

🔥 Fully-local simulator for Cloudflare Workers. For the latest version, see https://github.com/cloudflare/workers-sdk/tree/main/packages/miniflare.
https://miniflare.dev
MIT License
3.79k stars 205 forks source link

Miniflare gets a 403 on Images when passing request #97

Closed WalshyDev closed 2 years ago

WalshyDev commented 2 years ago

When calling fetch with Request or even an object with the Request headers ({ heders: request.headers }) returns a 403 on Images.

Running this code with Miniflare works as intended. It will fetch the image perfectly fine.

export default {
  fetch(req) {
    return fetch('https://imagedelivery.net/ZWd9g1K7eljCn_KDTu_MWA/083eb7b2-5392-4565-b69e-aff66acddd00/public');
  }
}

Running this code... returns a 403

export default {
  fetch(req) {
    return fetch('https://imagedelivery.net/ZWd9g1K7eljCn_KDTu_MWA/083eb7b2-5392-4565-b69e-aff66acddd00/public', req);
  }
}

image


I'm not sure what exactly in Miniflare or Images is causing this. It works perfectly fine if deployed. Seems some headers are just not being stripped properly and CF denies that.

Miniflare version: 2.0.0-rc.1

mrbbot commented 2 years ago

Hey! 👋 Looks like this was due to the Host and CF-Connecting-IP headers included when fetching. Will be fixed in the next release. 👍

mrbbot commented 2 years ago

Hey! 👋 miniflare@2.0.0-rc.2 has just been released, including the fix for this. You can find the changelog here.