fix: tenant dinamico desde BD - sin hardcodeo en frontend cliente

This commit is contained in:
2026-03-10 13:45:23 -06:00
parent 597286fff0
commit 6bc5145b9c
3 changed files with 36 additions and 23 deletions

View File

@@ -2,8 +2,6 @@ import { auth } from '$lib/stores/auth';
import { get } from 'svelte/store';
const API_BASE = '/api/v1';
const TENANT_SLUG = 'aduanasoft';
interface RequestOptions extends RequestInit {
params?: Record<string, string>;
}
@@ -34,7 +32,8 @@ async function request<T>(endpoint: string, options: RequestOptions = {}): Promi
headers.set('Content-Type', 'application/json');
}
headers.set('X-App', 'client');
headers.set('X-Tenant-Slug', TENANT_SLUG);
const slug = get(authStore)?.user?.tenant_slug || get(authStore)?.user?.tenant_id || '';
headers.set('X-Tenant-Slug', slug);
const response = await fetch(url, {
...init,
@@ -72,7 +71,8 @@ async function downloadFile(endpoint: string, filename: string): Promise<void> {
headers.set('X-Tenant-ID', authState.user.tenant_id);
}
headers.set('X-App', 'client');
headers.set('X-Tenant-Slug', TENANT_SLUG);
const slug = get(authStore)?.user?.tenant_slug || get(authStore)?.user?.tenant_id || '';
headers.set('X-Tenant-Slug', slug);
const response = await fetch(`${API_BASE}${endpoint}`, {
method: 'GET',