MCPcopy Create free account
hub / github.com/GetStream/stream-js / getBaseUrl

Method getBaseUrl

src/client.ts:377–397  ·  view source on GitHub ↗
(serviceName?: string)

Source from the content-addressed store, hash-verified

375 }
376
377 getBaseUrl(serviceName?: string) {
378 if (!serviceName) serviceName = 'api';
379
380 if (this.options.urlOverride && this.options.urlOverride[serviceName]) return this.options.urlOverride[serviceName];
381
382 const urlEnvironmentKey = serviceName === 'api' ? 'STREAM_BASE_URL' : `STREAM_${serviceName.toUpperCase()}_URL`;
383 if (typeof process !== 'undefined' && process.env?.[urlEnvironmentKey])
384 return process.env[urlEnvironmentKey] as string;
385
386 if ((typeof process !== 'undefined' && process.env?.LOCAL) || this.options.local)
387 return `http://localhost:8000/${serviceName}/`;
388
389 if (this.location) {
390 const protocol = this.options.protocol || 'https';
391 return `${protocol}://${this.location}-${serviceName}.stream-io-api.com/${serviceName}/`;
392 }
393
394 if (serviceName !== 'api') return `https://${serviceName}.stream-io-api.com/${serviceName}/`;
395
396 return this.baseUrl;
397 }
398
399 /**
400 * Support for global event callbacks

Callers 3

constructorMethod · 0.95
enrichUrlMethod · 0.95
test.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected