This commit is contained in:
alma 2025-05-22 18:42:30 +02:00
parent f4a730422c
commit a7428913d0

View File

@ -15,6 +15,17 @@ interface MissionUserInput {
// Helper function to check authentication
async function checkAuth(request: Request) {
// Check for API key first
const apiKey = request.headers.get('x-api-key');
console.log('Received API key:', apiKey);
console.log('Expected API key:', process.env.N8N_API_KEY);
console.log('API key match:', apiKey === process.env.N8N_API_KEY);
if (apiKey === process.env.N8N_API_KEY) {
return { authorized: true, userId: 'system' };
}
// If no API key, check for session
const session = await getServerSession(authOptions);
if (!session?.user?.id) {
console.error('Unauthorized access attempt:', {