diff options
Diffstat (limited to 'apps/mobile/lib/utils.ts')
| -rw-r--r-- | apps/mobile/lib/utils.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/apps/mobile/lib/utils.ts b/apps/mobile/lib/utils.ts index bfb6c9ed..ce729826 100644 --- a/apps/mobile/lib/utils.ts +++ b/apps/mobile/lib/utils.ts @@ -42,3 +42,18 @@ export function condProps( return condition ? { ...acc, ...props } : acc; }, {}); } + +/** + * Build HTTP headers for API requests, merging Authorization and custom headers. + * This ensures all direct HTTP calls (uploads, downloads, health checks) respect + * the user's custom header configuration. + */ +export function buildApiHeaders( + apiKey: string | undefined, + customHeaders: Record<string, string> = {}, +): Record<string, string> { + return { + ...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}), + ...customHeaders, + }; +} |
