feat: versão 1.5 - CRM Beta com leads, funis, campanhas e portal do cliente
This commit is contained in:
55
front-end-agency/app/api/agency/branding/route.ts
Normal file
55
front-end-agency/app/api/agency/branding/route.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
// Obter subdomain do header (definido pelo middleware)
|
||||
const subdomain = request.headers.get('x-tenant-subdomain');
|
||||
|
||||
if (!subdomain) {
|
||||
console.log('[Branding API] Subdomain não encontrado nos headers');
|
||||
return NextResponse.json(
|
||||
{ error: 'Subdomain não identificado' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
console.log(`[Branding API] Buscando tenant para subdomain: ${subdomain}`);
|
||||
|
||||
// Buscar tenant por subdomain
|
||||
const response = await fetch(`http://aggios-backend:8080/api/tenant/check?subdomain=${subdomain}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
cache: 'no-store',
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(`[Branding API] Erro ao buscar tenant: ${response.status}`);
|
||||
return NextResponse.json(
|
||||
{ error: 'Tenant não encontrado' },
|
||||
{ status: response.status }
|
||||
);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
console.log(`[Branding API] Tenant encontrado:`, {
|
||||
id: data.tenant?.id,
|
||||
name: data.tenant?.name,
|
||||
subdomain: data.tenant?.subdomain
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
primary_color: data.tenant?.primary_color || '#6366f1',
|
||||
logo_url: data.tenant?.logo_url,
|
||||
company: data.tenant?.name || data.tenant?.company,
|
||||
tenant_id: data.tenant?.id,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[Branding API] Erro:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Erro ao buscar branding' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user