-
Notifications
You must be signed in to change notification settings - Fork 12
fix: pass all required env vars to edge function invocations #342
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -453,27 +453,32 @@ export class NetlifyDev { | |
| } | ||
|
|
||
| if (this.#features.edgeFunctions) { | ||
| const env = Object.entries(envVariables).reduce<Record<string, string>>((acc, [key, variable]) => { | ||
| if ( | ||
| variable.usedSource === 'account' || | ||
| variable.usedSource === 'addons' || | ||
| variable.usedSource === 'internal' || | ||
| variable.usedSource === 'ui' || | ||
| variable.usedSource.startsWith('.env') | ||
| ) { | ||
| return { | ||
| const edgeFunctionsEnv = { | ||
| // User-defined env vars + documented runtime env vars | ||
| ...Object.entries(envVariables).reduce<Record<string, string>>( | ||
| (acc, [key, variable]) => ({ | ||
| ...acc, | ||
| [key]: variable.value, | ||
| } | ||
| } | ||
|
|
||
| return acc | ||
| }, {}) | ||
| }), | ||
| {}, | ||
| ), | ||
| // Add runtime env vars that we've set ourselves so far. These are "internal" env vars, | ||
| // part of the runtime emulation. They've already been populated on this process's env, which | ||
| // is needed to make other dev features work. These are different than the "documented" runtime | ||
| // env vars, in that they are implementation details, needed to make our features work. | ||
| ...Object.keys(runtime.envSnapshot).reduce<Record<string, string>>( | ||
| (acc, key) => ({ | ||
| ...acc, | ||
| [key]: runtime.env.get(key) ?? '', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this fallback ever kick in?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it should be possible, but the type returns |
||
| }), | ||
| {}, | ||
| ), | ||
| } | ||
|
|
||
| const edgeFunctionsHandler = new EdgeFunctionsHandler({ | ||
| configDeclarations: this.#config?.config.edge_functions ?? [], | ||
| directories: [this.#config?.config.build.edge_functions].filter(Boolean) as string[], | ||
| env, | ||
| env: edgeFunctionsEnv, | ||
| geolocation: mockLocation, | ||
| logger: this.#logger, | ||
| siteID, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no coverage for the unlinked site case. This is copied and tweaked from the linked site test.
It's rather important for env vars because there's a whole separate code path with the envelope stuff when linked.