Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/new-houses-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'e2b': patch
'@e2b/cli': patch
---

Support overriding apiUrl via E2B_API_URL
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 ??
Copy link
Member

Choose a reason for hiding this comment

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

Missing property that get's the value from the env var.

(this.debug ? 'http://localhost:3000' : `https://api.${this.domain}`)
}

private static get domain() {
Expand Down