Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / packages/utils/get-base-url.ts |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | packages/utils/get-base-url.ts |
| Original SHA-256 | 51452164d570165b2a8194e0fd3f90f3d1bb46077dd9169d0ee383ab3e47248c |
| Git blob SHA | 853962412391d9fc96fd86f0e73429a99b2308a0 |
| Reading-copy SHA-256 | 51452164d570165b2a8194e0fd3f90f3d1bb46077dd9169d0ee383ab3e47248c |
Recovered source transcript
Download complete source text ↓28 lines · 0.7 KB
/**
* Returns the base URL for the application based on the current environment.
* Automatically detects Vercel deployment URLs and falls back to development URL.
*
* @returns The base URL for the application
*
* @example
* ```ts
* const baseUrl = getBaseUrl()
* // Returns 'https://your-domain.vercel.app' in production
* // Returns 'http://localhost:3000' in development
* ```
*/
export function getBaseUrl(): string {
// Custom domain URL
if (process.env.NEXT_PUBLIC_WEB_URL) {
return process.env.NEXT_PUBLIC_WEB_URL
}
// Vercel deployment URL
if (process.env.VERCEL_URL) {
return `https://${process.env.VERCEL_URL}`
}
// Development URL
return 'http://localhost:3000'
}