How to access `.env` with Wrangler 2

#166 · closed · 2 comments

View on GitHub ↗

taviks

I'm in the process of updating a Wrangler 1 project that uses Worktop next with Wrangler 2 and can't figure out how to access entries in my `.env` file. Previously, I used miniflare and passed the `--env` flag. E.g. ``` miniflare --env '.env' ``` Wrangler 2 does not support Miniflare commands directly. Reading [this](https://github.com/cloudflare/wrangler2/issues/1043#issuecomment-1129000582), it seems that perhaps Worktop should be passing a second `env` argument to the handler but it's not. Any ideas?

Comments

lukeed

Hi there, worktop doesn’t interact with env files at all. That is entirely reliant upon wrangler and/or miniflare. That said, wrangler 2 should have (or soon have) restored .env file support: https://github.com/cloudflare/wrangler2/pull/882 hope that helps

taviks

Ah, I see... very helpful. Thank you, @lukeed!