- API key auth via x-openclaw-key header (OPENCLAW_API_KEY env var)
- GET /api/openclaw/sync/status
- POST /api/openclaw/sync/autotask/incremental
- POST /api/openclaw/sync/autotask/full
- POST /api/openclaw/sync/autotask/entity { entities: [...] }
- POST /api/openclaw/sync/datto-rmm { syncType: full|incremental }
- POST /api/openclaw/sync/sentinelone
- POST /api/openclaw/sync/veeam { syncType: full|incremental }
- POST /api/openclaw/sync/zoom
- POST /api/openclaw/sync/engagement
- POST /api/openclaw/sync/qbo { syncType: full|incremental }
- POST /api/openclaw/sync/zabbix
- POST /api/openclaw/sync/itglue
All routes bypass Better Auth middleware, delegate to existing sync services
22 lines
706 B
TypeScript
22 lines
706 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
|
|
/**
|
|
* Validate the OpenClaw API key from the request header.
|
|
* Returns a 401 NextResponse if invalid, or null if valid.
|
|
*/
|
|
export function validateOpenClawKey(request: NextRequest): NextResponse | null {
|
|
const expectedKey = process.env.OPENCLAW_API_KEY;
|
|
|
|
if (!expectedKey) {
|
|
console.error('[OpenClaw] OPENCLAW_API_KEY is not set');
|
|
return NextResponse.json({ error: 'OpenClaw API not configured' }, { status: 500 });
|
|
}
|
|
|
|
const providedKey = request.headers.get('x-openclaw-key');
|
|
|
|
if (!providedKey || providedKey !== expectedKey) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
}
|
|
|
|
return null;
|
|
}
|