-
Notifications
You must be signed in to change notification settings - Fork 747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support .env via miniflare #190
Comments
Yeah, maybe. I'm thinking deeply about vars/secrets lately. It'll likely involve dotenv, or something similar. I'll assign this to myself atm. |
This became an issue for me. I'm trying to convert a Remix application running on Vercel to Cloudflare Pages and had to connect to Discord to understand why this does not work (which made me comment this for future reference)
|
Would you mind if I make a PR implementing this? I think passing |
@threepointone so what is on your mind? Can @BasixKOR move forward with |
We haven't taken a call here yet. It has to apply in both local and edge mode, (and not just pages) and we don't want to create a dependency without understanding it deeply. We may likely go with dotenv, but we just haven't taken a call yet. |
Ah, I haven't given a thought about edge mode. My thought was that since Miniflare already supports importing a .env file we could pass the path of the file, but this wouldn't work on edge mode. My implementation (which I'm using right now) is here: https://github.com/BasixKOR/wrangler2/tree/dotenv |
Perhaps we could add support for two variants of .env files: wrangler.env and runtime.env? The former would be provided to Wrangler (i.e. for bundling in publish and dev, and for specifying things like CLOUDFLARE_API_TOKEN for many of the commands that need to access the Cloudflare API). |
The `vars` bindings can be specified in the `wrangler.toml` configuration file. But "secret" `vars` are usually only provided at the server - either by creating them in the Dashboard UI, or using the `wrangler secret` command. It is useful during development, to provide these types of variable locally. When running `wrangler dev` we will look for a file called `.dev.vars`, situated next to the `wrangler.toml` file (or in the current working directory if there is no `wrangler.toml`). Any values in this file, formatted like a `dotenv` file, will add to or override `vars` bindings provided in the `wrangler.toml`. Related to cloudflare#190
The `vars` bindings can be specified in the `wrangler.toml` configuration file. But "secret" `vars` are usually only provided at the server - either by creating them in the Dashboard UI, or using the `wrangler secret` command. It is useful during development, to provide these types of variable locally. When running `wrangler dev` we will look for a file called `.dev.vars`, situated next to the `wrangler.toml` file (or in the current working directory if there is no `wrangler.toml`). Any values in this file, formatted like a `dotenv` file, will add to or override `vars` bindings provided in the `wrangler.toml`. Related to cloudflare#190
The `vars` bindings can be specified in the `wrangler.toml` configuration file. But "secret" `vars` are usually only provided at the server - either by creating them in the Dashboard UI, or using the `wrangler secret` command. It is useful during development, to provide these types of variable locally. When running `wrangler dev` we will look for a file called `.dev.vars`, situated next to the `wrangler.toml` file (or in the current working directory if there is no `wrangler.toml`). Any values in this file, formatted like a `dotenv` file, will add to or override `vars` bindings provided in the `wrangler.toml`. Related to cloudflare#190
…file This change will automatically load up a `.env` file, if found, and apply its values to the current environment. An example would be to provide a specific CLOUDFLARE_ACCOUNT_ID value. Related to cloudflare#190
…file This change will automatically load up a `.env` file, if found, and apply its values to the current environment. An example would be to provide a specific CLOUDFLARE_ACCOUNT_ID value. Related to cloudflare#190
…file This change will automatically load up a `.env` file, if found, and apply its values to the current environment. An example would be to provide a specific CLOUDFLARE_ACCOUNT_ID value. Related to cloudflare#190
…file This change will automatically load up a `.env` file, if found, and apply its values to the current environment. An example would be to provide a specific CLOUDFLARE_ACCOUNT_ID value. Related to cloudflare#190
The `vars` bindings can be specified in the `wrangler.toml` configuration file. But "secret" `vars` are usually only provided at the server - either by creating them in the Dashboard UI, or using the `wrangler secret` command. It is useful during development, to provide these types of variable locally. When running `wrangler dev` we will look for a file called `.dev.vars`, situated next to the `wrangler.toml` file (or in the current working directory if there is no `wrangler.toml`). Any values in this file, formatted like a `dotenv` file, will add to or override `vars` bindings provided in the `wrangler.toml`. Related to cloudflare#190
reopening, waiting on #879 as well |
* test: use `fs` consistently in dev tests * feat: read `vars` overrides from a local file for `wrangler dev` The `vars` bindings can be specified in the `wrangler.toml` configuration file. But "secret" `vars` are usually only provided at the server - either by creating them in the Dashboard UI, or using the `wrangler secret` command. It is useful during development, to provide these types of variable locally. When running `wrangler dev` we will look for a file called `.dev.vars`, situated next to the `wrangler.toml` file (or in the current working directory if there is no `wrangler.toml`). Any values in this file, formatted like a `dotenv` file, will add to or override `vars` bindings provided in the `wrangler.toml`. Related to #190
Thank you, folks! |
Miniflare automatically supports picking up the content of .env files. This is a very common practice in Node environments and is especially handy when building projects with frameworks like Remix that support multiple deployment targets. I think it would be beneficial and very handy to add support for this on wrangler2.
The text was updated successfully, but these errors were encountered: