Images binding locally with vite

This page teaches how to run the images binding locally with wrangler but not if we’re using vite. has anyone managed to make it work while running vite? e.g.: environments in vite are passed as the CLOUDFLARE_ENV env variable.
Cloudflare Docs
Bind to Workers API
A binding connects your Worker to external resources on the Developer Platform, like Images, R2 buckets, or KV Namespaces.
11 Replies
top kek
top kekOP3mo ago
the reason why i want this is that some members of my team do not have access to cloudflare but still develop locally
Razboy20
Razboy203mo ago
Hm, my understanding is that you should be able to access bindings through the vite plugin as you would normally
top kek
top kekOP3mo ago
sorry that’s not what i mean. i mean the experimental flag to run the image binding locally. if we don’t turn it then we need to login and the binding runs over a network request to cf
Razboy20
Razboy203mo ago
Could you elaborate a bit more on how you're trying to use the bindings through vite? (what's the stack)
top kek
top kekOP3mo ago
react router + vite + cloudflare’s wrangler vite plugin
Razboy20
Razboy203mo ago
gotcha—so you're trying to use the experimental flag to run the image binding locally, with the vite plugin
top kek
top kekOP3mo ago
yes exactly
Razboy20
Razboy203mo ago
@freddie spent a while reading wrangler/vite plugin source code, it may be possible to set some value within .wrangler/deploy/config.json to enable this
Razboy20
Razboy203mo ago
but I'm honestly not sure
top kek
top kekOP3mo ago
i’ll give it a go today! the alternative is just not running images through it in dev mode which is just lower fidelity but works

Did you find this page helpful?