xref: /expo/packages/@expo/cli/src/api/endpoint.ts (revision f2de99f7)
1import { env } from '../utils/env';
2import { getFreePortAsync } from '../utils/port';
3
4/** Get the URL for the expo.dev API. */
5export function getExpoApiBaseUrl(): string {
6  if (env.EXPO_STAGING) {
7    return `https://staging-api.expo.dev`;
8  } else if (env.EXPO_LOCAL) {
9    return `http://127.0.0.1:3000`;
10  } else {
11    return `https://api.expo.dev`;
12  }
13}
14
15/** Get the URL for the expo.dev website. */
16export function getExpoWebsiteBaseUrl(): string {
17  if (env.EXPO_STAGING) {
18    return `https://staging.expo.dev`;
19  } else if (env.EXPO_LOCAL) {
20    return `http://127.0.0.1:3001`;
21  } else {
22    return `https://expo.dev`;
23  }
24}
25
26export async function getSsoLocalServerPortAsync(): Promise<number> {
27  const startPort = env.EXPO_SSO_LOCAL_SERVER_PORT;
28  return await getFreePortAsync(startPort);
29}
30