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
The way backend url option is defaulted is error-prone.
Right now:
functionsetupClient(options: NextjsOptions){constclient=newConvexHttpClient(getConvexUrl(options.url,options.skipConvexDeploymentUrlCheck??false),);if(options.token!==undefined){client.setAuth(options.token);}if(options.adminToken!==undefined){client.setAdminAuth(options.adminToken);}client.setFetchOptions({cache: "no-store"});returnclient;}functiongetConvexUrl(deploymentUrl: string|undefined,skipConvexDeploymentUrlCheck: boolean,){consturl=deploymentUrl??process.env.NEXT_PUBLIC_CONVEX_URL;constisFromEnv=deploymentUrl===undefined;if(typeofurl!=="string"){thrownewError(isFromEnv
? `Environment variable NEXT_PUBLIC_CONVEX_URL is not set.`
: `Convex function called with invalid deployment address.`,);}if(!skipConvexDeploymentUrlCheck){validateDeploymentUrl(url);}returnurl!;}
This means that if I call preloadQuery(api.foo.bla, {}., {url: process.env.MY_VAR}) when MY_VAR is not used the code falls back to NEXT_PUBLIC_CONVEX_URL. It would be better to check whether 'url' in options and default based on that, throwing early if the provided url is undefined.
Fixing this would unfortunately be a breaking change in the strict definition of breaking.
The text was updated successfully, but these errors were encountered:
The way backend
url
option is defaulted is error-prone.Right now:
This means that if I call
preloadQuery(api.foo.bla, {}., {url: process.env.MY_VAR})
when MY_VAR is not used the code falls back toNEXT_PUBLIC_CONVEX_URL
. It would be better to check whether'url' in options
and default based on that, throwing early if the provided url isundefined
.Fixing this would unfortunately be a breaking change in the strict definition of breaking.
The text was updated successfully, but these errors were encountered: