Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 613 Bytes
a8fb296 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // Attach the stored bearer token to admin/control-plane fetches.
//
// The batch-jobs and deployments clients use plain fetch() (their endpoints
// aren't in the generated OpenAPI client), so they bypass the Authorization
// logic in lib/api.ts. These endpoints are admin-gated on the backend
// (require_admin), so every call must carry the JWT. Use this helper to build
// the headers.
export function authHeaders(
base: Record<string, string> = {},
): Record<string, string> {
const token = localStorage.getItem('auth_token')
return token ? { ...base, Authorization: `Bearer ${token}` } : { ...base }
}
|