@devries-cameron20 / composio Mirror · read-only
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 03:37 UTC

next
mjs 30 lines 948 Bytes
Raw
1 export const STAGING_BASE_URL = 'https://staging-backend.composio.dev';
2
3 // Resolves the backend the examples run against: whatever COMPOSIO_BASE_URL
4 // says, defaulting to staging. The structural checks are not about which
5 // backend it is — a base URL carrying a path, query, fragment, or embedded
6 // credentials means the caller meant something else, and the origin
7 // normalisation below only holds for a bare root.
8 export const resolveBackendBaseUrl = (
9 value = process.env.COMPOSIO_BASE_URL ?? STAGING_BASE_URL
10 ) => {
11 let url;
12 try {
13 url = new URL(value);
14 } catch {
15 throw new Error(`refusing invalid COMPOSIO_BASE_URL: ${value}`);
16 }
17
18 const isBareHttpsRoot =
19 url.protocol === 'https:' &&
20 url.pathname === '/' &&
21 !url.search &&
22 !url.hash &&
23 !url.username &&
24 !url.password;
25 if (!isBareHttpsRoot) {
26 throw new Error(`refusing malformed COMPOSIO_BASE_URL: ${value}`);
27 }
28
29 return url.origin;
30 };