fix: tenant dinamico desde BD - sin hardcodeo en frontend cliente
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user