Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix cloud API url

Nick Sweeting42579c05a48e
diff --git a/CLAUDE.md b/CLAUDE.md
index 9de9a0c29..87a2365c0 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -12,7 +12,7 @@ We want our library APIs to be ergonomic, intuitive, and hard to get wrong.
- We keep the main code for each sub-component in a `service.py` file usually, and we keep most pydantic models in `views.py` files unless they are long enough deserve their own file
- Use runtime assertions at the start and end of functions to enforce constraints and assumptions
- Prefer `from uuid_extensions import uuid7str` + `id: str = Field(default_factory=uuid7str)` for all new id fields
-- Run tests using `uv run pytest -vx tests/ci`
+- Run tests using `uv run pytest -vxs tests/ci`
- Run the type checker using `uv run pyright`
## Keep Examples & Tests Up-To-Date
diff --git a/browser_use/config.py b/browser_use/config.py
index 156222f41..f36d8cf3f 100644
--- a/browser_use/config.py
+++ b/browser_use/config.py
@@ -54,9 +54,9 @@ class Config:
return os.getenv('BROWSER_USE_CLOUD_SYNC', str(self.ANONYMIZED_TELEMETRY)).lower()[:1] in 'ty1'
@property
- def BROWSER_USE_CLOUD_URL(self) -> str:
- url = os.getenv('BROWSER_USE_CLOUD_URL', 'https://cloud.browser-use.com')
- assert '://' in url, 'BROWSER_USE_CLOUD_URL must be a valid URL'
+ def BROWSER_USE_CLOUD_API_URL(self) -> str:
+ url = os.getenv('BROWSER_USE_CLOUD_API_URL', 'https://api.browser-use.com')
+ assert '://' in url, 'BROWSER_USE_CLOUD_API_URL must be a valid URL'
return url
@property
diff --git a/browser_use/sync/auth.py b/browser_use/sync/auth.py
index b1e32f1a8..b0bd6c834 100644
--- a/browser_use/sync/auth.py
+++ b/browser_use/sync/auth.py
@@ -61,7 +61,7 @@ class DeviceAuthClient:
def __init__(self, base_url: str | None = None, http_client: httpx.AsyncClient | None = None):
# Backend API URL for OAuth requests - can be passed directly or defaults to env var
- self.base_url = base_url or CONFIG.BROWSER_USE_CLOUD_URL
+ self.base_url = base_url or CONFIG.BROWSER_USE_CLOUD_API_URL
self.client_id = 'library'
self.scope = 'read write'
@@ -257,7 +257,7 @@ class DeviceAuthClient:
device_auth = await self.start_device_authorization(agent_session_id)
# Use frontend URL for user-facing links
- frontend_url = CONFIG.BROWSER_USE_CLOUD_UI_URL or self.base_url
+ frontend_url = CONFIG.BROWSER_USE_CLOUD_UI_URL or self.base_url.replace('//api.', '//cloud.')
# Replace backend URL with frontend URL in verification URIs
verification_uri = device_auth['verification_uri'].replace(self.base_url, frontend_url)
diff --git a/browser_use/sync/service.py b/browser_use/sync/service.py
index 8ebe5bf33..c3d9e0b13 100644
--- a/browser_use/sync/service.py
+++ b/browser_use/sync/service.py
@@ -21,7 +21,7 @@ class CloudSync:
def __init__(self, base_url: str | None = None, enable_auth: bool = True):
# Backend API URL for all API requests - can be passed directly or defaults to env var
- self.base_url = base_url or CONFIG.BROWSER_USE_CLOUD_URL
+ self.base_url = base_url or CONFIG.BROWSER_USE_CLOUD_API_URL
self.enable_auth = enable_auth
self.auth_client = DeviceAuthClient(base_url=self.base_url) if enable_auth else None
self.pending_events: list[BaseEvent] = []
@@ -75,7 +75,9 @@ class CloudSync:
self.pending_events.append(event)
elif response.status_code >= 400:
# Log error but don't raise - we want to fail silently
- logger.warning(f'Failed to send event to cloud: HTTP {response.status_code} - {response.text[:200]}')
+ logger.warning(
+ f'Failed to send event to cloud: POST {response.request.url} {response.status_code} - {response.text[:200]}'
+ )
except httpx.TimeoutException:
logger.warning(f'⚠️ Event send timed out after 10 seconds: {event}')
except httpx.ConnectError as e:
diff --git a/tests/ci/conftest.py b/tests/ci/conftest.py
index e52e91c1e..040853396 100644
--- a/tests/ci/conftest.py
+++ b/tests/ci/conftest.py
@@ -42,7 +42,7 @@ def setup_test_environment():
'SKIP_LLM_API_KEY_VERIFICATION': 'true',
'ANONYMIZED_TELEMETRY': 'false',
'BROWSER_USE_CLOUD_SYNC': 'true',
- 'BROWSER_USE_CLOUD_URL': 'http://placeholder-will-be-replaced-by-specific-test-fixtures',
+ 'BROWSER_USE_CLOUD_API_URL': 'http://placeholder-will-be-replaced-by-specific-test-fixtures',
'BROWSER_USE_CLOUD_UI_URL': 'http://placeholder-will-be-replaced-by-specific-test-fixtures',
'BROWSER_USE_CONFIG_DIR': config_dir,
}
@@ -169,7 +169,7 @@ def cloud_sync(httpserver: HTTPServer):
# Set up test environment
test_http_server_url = httpserver.url_for('')
- os.environ['BROWSER_USE_CLOUD_URL'] = test_http_server_url
+ os.environ['BROWSER_USE_CLOUD_API_URL'] = test_http_server_url
os.environ['BROWSER_USE_CLOUD_UI_URL'] = test_http_server_url
os.environ['BROWSER_USE_CLOUD_SYNC'] = 'true'
diff --git a/tests/old/sync_live.py b/tests/old/sync_live.py
index 74397cc1d..6d39cc760 100644
--- a/tests/old/sync_live.py
+++ b/tests/old/sync_live.py
@@ -77,11 +77,11 @@
# Environment variables required:
# - RUN_LIVE_TESTS=1 (to enable the test)
-# - BROWSER_USE_CLOUD_URL (optional, defaults to https://cloud.browser-use.com)
+# - BROWSER_USE_CLOUD_API_URL (optional, defaults to https://cloud.browser-use.com)
# """
# # Configuration
-# backend_url = os.getenv('BROWSER_USE_CLOUD_URL', 'http://localhost:8000')
+# backend_url = os.getenv('BROWSER_USE_CLOUD_API_URL', 'http://localhost:8000')
# logger.info(f'Running live integration test against: {backend_url}')
# # Create mock LLM
@@ -89,7 +89,7 @@
# # Set environment variables for cloud sync
# os.environ['BROWSERUSE_CLOUD_SYNC'] = 'true'
-# os.environ['BROWSER_USE_CLOUD_URL'] = backend_url
+# os.environ['BROWSER_USE_CLOUD_API_URL'] = backend_url
# # Create browser session with real profile
# browser_session = BrowserSession(
@@ -147,7 +147,7 @@
# This is a simpler test that just verifies event sending works.
# """
-# backend_url = os.getenv('BROWSER_USE_CLOUD_URL', 'http://localhost:8000')
+# backend_url = os.getenv('BROWSER_USE_CLOUD_API_URL', 'http://localhost:8000')
# logger.info(f'Testing cloud sync against: {backend_url}')
# # Create cloud sync service