Skip to content
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

.env file wrong behavior (v2) #75

Closed
payellodevsupport opened this issue Oct 29, 2021 · 0 comments
Closed

.env file wrong behavior (v2) #75

payellodevsupport opened this issue Oct 29, 2021 · 0 comments

Comments

@payellodevsupport
Copy link
Contributor

The below should output dev not sandbox as the .env file should override the wrangler variables.
This happens only in v2. v1 is fine.

wrangler.toml:

name = "test"
type = "javascript"

[build.upload]
format = "modules"
main = "./index.mjs"

[env.dev]
account_id = "-REDACTED-"
zone_id = "-REDACTED-"
workers_dev = true

[env.dev.vars]
ENV = "sandbox"

.env

ENV=dev

Test script:

interface Env {
   ENV: string
}

export default {
  async fetch(request: Request, env: Env, ctx: ExecutionContext) {
    console.log(env.ENV)
    return new Response(null, { status: 404 })
  }
}

Miniflare command:

miniflare -w -m --wrangler-env "dev" --env ".env"

Output:

sandbox
payellodevsupport added a commit to payellodevsupport/miniflare that referenced this issue Oct 29, 2021
Moved the .env file parsing code to the end of the method so that it overrides WASM variables
mrbbot added a commit that referenced this issue Oct 29, 2021
Move .env file parsing code to end. Fixes #75
mrbbot pushed a commit that referenced this issue Jan 7, 2022
Moved the .env file parsing code to the end of the method so that it overrides WASM variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant