(req: NextRequest)
| 85 | } |
| 86 | |
| 87 | export function checkInternalApiKey(req: NextRequest) { |
| 88 | const apiKey = req.headers.get('x-api-key') |
| 89 | const expectedApiKey = env.INTERNAL_API_SECRET |
| 90 | |
| 91 | if (!expectedApiKey) { |
| 92 | return { success: false, error: 'Internal API key not configured' } |
| 93 | } |
| 94 | |
| 95 | if (!apiKey) { |
| 96 | return { success: false, error: 'API key required' } |
| 97 | } |
| 98 | |
| 99 | if (!safeCompare(apiKey, expectedApiKey)) { |
| 100 | return { success: false, error: 'Invalid API key' } |
| 101 | } |
| 102 | |
| 103 | return { success: true } |
| 104 | } |
no test coverage detected