Hdhdjdjd dhjdbd hjdhd commited on
Commit
f61d6ba
·
1 Parent(s): 3d8743c

Deploy Zone.ID Domain API 2025-12-07

Browse files
Files changed (1) hide show
  1. src/server.js +6 -19
src/server.js CHANGED
@@ -68,28 +68,15 @@ async function build() {
68
 
69
  if (isPublic) return;
70
 
71
- const apiKey = request.headers['x-api-key'];
72
- if (!apiKey) {
73
- reply.code(401).send({ error: 'API key required' });
74
  return;
75
  }
76
 
77
- const { PrismaClient } = require('@prisma/client');
78
- const prisma = new PrismaClient();
79
-
80
- try {
81
- const key = await prisma.apiKey.findUnique({ where: { key: apiKey } });
82
- if (!key || !key.isActive) {
83
- reply.code(401).send({ error: 'Invalid API key' });
84
- return;
85
- }
86
-
87
- await prisma.apiKey.update({
88
- where: { id: key.id },
89
- data: { lastUsedAt: new Date() }
90
- });
91
- } finally {
92
- await prisma.$disconnect();
93
  }
94
  });
95
 
 
68
 
69
  if (isPublic) return;
70
 
71
+ const expectedApiKey = process.env.API_KEY;
72
+ if (!expectedApiKey) {
 
73
  return;
74
  }
75
 
76
+ const apiKey = request.headers['x-api-key'];
77
+ if (!apiKey || apiKey !== expectedApiKey) {
78
+ reply.code(401).send({ error: 'Invalid or missing API key' });
79
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
  });
82