Skip to content
Open
2 changes: 2 additions & 0 deletions packages/cli/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
nodejs 20
pnpm 9
1 change: 1 addition & 0 deletions packages/cli/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ const userConfig = getUserConfig()
export const connectionConfig = new e2b.ConnectionConfig({
accessToken: process.env.E2B_ACCESS_TOKEN || userConfig?.accessToken,
apiKey: process.env.E2B_API_KEY || userConfig?.teamApiKey,
apiUrl: process.env.E2B_API_URL,
})
export const client = new e2b.ApiClient(connectionConfig)
10 changes: 7 additions & 3 deletions packages/js-sdk/src/connectionConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export interface ConnectionOpts {
* @default E2B_DOMAIN // environment variable or `e2b.app`
*/
domain?: string
/**
* API Url to use for the API.
*/
apiUrl?: string
/**
* If true the SDK starts in the debug mode and connects to the local envd API server.
* @internal
Expand Down Expand Up @@ -78,9 +82,9 @@ export class ConnectionConfig {
this.headers = opts?.headers || {}
this.headers['User-Agent'] = `e2b-js-sdk/${version}`

this.apiUrl = this.debug
? 'http://localhost:3000'
: `https://api.${this.domain}`
this.apiUrl = opts?.apiUrl ?? (
this.debug ? 'http://localhost:3000' : `https://api.${this.domain}`
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: API URL Config Inconsistency

The apiUrl option's fallback logic is inconsistent with other config options. It doesn't read the E2B_API_URL environment variable by default, and the ?? operator doesn't treat empty strings as invalid, which can cause network requests to fail.

Fix in Cursor Fix in Web

}

private static get domain() {
Expand Down
Loading