Skip to content

edge-functions: Deno.env should contain the same environment variables as in production #4614

Description

@Skn0tt

Describe the bug

Running edge functions locally with netlify dev, Deno.env contains all environment variables inherited from the CLI's shell. This is different from production, where it will only contain env vars specified in the Netlify UI, and two Deno-specific ones. This should be replicated in local dev.

One possible solution is to work with downstream @netlify/edge-bundler, and pass the --allow-env=... flag to only allow access to the environment variables that'd also exist in production:

https://github.com/netlify/edge-bundler/blob/0d2c6af674d30f0322bf376ad66acb0d5b5b0124/src/server/server.ts#L113

Steps to reproduce

Write an edge function, log Deno.env.toObject(). It should contain just placeholders for DENO_REGION and DENO_DEPLOYMENT_ID (probably not even that), but instead it contains all env vars inherited from the CLI's shell.

Configuration

No response

Environment

not relevant

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions