You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cannot use sdk's get method on Vite @^3.0.8 as it defaults to process.env.EDGE_CONFIG.
Instead it should accept a parameter for edge config, OR support Vite bundler.
I'm guessing it happens when we try to read EDGE_CONFIG var key in the init function in index.edge.ts file:
// lazy init fn so the default edge config does not throw in case// process.env.EDGE_CONFIG is not defined and its methods are never used.functioninit(): void{// eslint-disable-next-line @typescript-eslint/no-unnecessary-conditionif(!defaultEdgeConfigClient){defaultEdgeConfigClient=createClient(process.env.EDGE_CONFIG);}}
How to reproduce:
create a new project with Vite
install vercel's edge config sdk
paste the middleware code I posted above
call it
see the error
Proposed fix for the init function:
Update the init function:
// lazy init fn so the default edge config does not throw in case
// process.env.EDGE_CONFIG is not defined and its methods are never used.
function init(edgeConfig: string): void {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!defaultEdgeConfigClient) {
defaultEdgeConfigClient = createClient(edgeConfig);
}
}
Update the get function and so on.... Ill gladly make a PR with the fix if you guys think it makes sense.
The text was updated successfully, but these errors were encountered:
The solution for Vite is to construct the client using your connection string:
import{createClient}from'@vercel/edge-config';constclient=createClient(/* your connection string */);// client now has access to `get` and the other methods
Cannot use sdk's get method on Vite @^3.0.8 as it defaults to process.env.EDGE_CONFIG.
Instead it should accept a parameter for edge config, OR support Vite bundler.
Code example:
Error when trying to call middleware function:
I'm guessing it happens when we try to read EDGE_CONFIG var key in the init function in index.edge.ts file:
How to reproduce:
Proposed fix for the init function:
Update the init function:
Update the get function and so on.... Ill gladly make a PR with the fix if you guys think it makes sense.
The text was updated successfully, but these errors were encountered: