fix(middleware): permitir x-api-key en rutas /api/ para integraciones y tests
This commit is contained in:
@@ -59,8 +59,19 @@ export async function middleware(req: NextRequest) {
|
||||
const url = req.nextUrl.clone();
|
||||
const path = url.pathname;
|
||||
|
||||
const apiKeyHeader =
|
||||
req.headers.get('x-api-key') ||
|
||||
req.headers.get('authorization')?.replace(/^Bearer\s+/i, '');
|
||||
const isApiKeyAuth =
|
||||
Boolean(apiKeyHeader) &&
|
||||
apiKeyHeader ===
|
||||
(process.env.INTEGRATIONS_API_KEY ||
|
||||
process.env.N8N_API_KEY ||
|
||||
'n8n_sec_4v_9a7d3b2c1f8e4a5d6c7b8a9e0f1a2b3c');
|
||||
|
||||
// Public: login, attribution script, health, inbound webhooks (CRM), cron (Bearer CRON_SECRET), integrations (API Key)
|
||||
const isPublic =
|
||||
(isApiKeyAuth && path.startsWith('/api/')) ||
|
||||
path === '/login' ||
|
||||
path === '/api/health' ||
|
||||
path.startsWith('/api/webhooks/') ||
|
||||
|
||||
Reference in New Issue
Block a user