feat: adding only the key

This commit is contained in:
Carlos
2025-04-18 23:28:08 -04:00
parent 504b5ba04e
commit b0563abc99

View File

@ -11,28 +11,6 @@ app.use(bodyParser.json());
// API Key validation middleware
const validateApiKey = (req, res, next) => {
const trustedIps = [
"2600:1702:6f0a:3c00:d065:e1b4:ac3b:d889", // Cloudflare real IP
"2600:1702:6f0a:3c00:6525:1a53:cca3:cdcf",
"192.168.1.149",
"144.160.240.69", // another ip
"::1", // localhost IPv6
"127.0.0.1", // localhost IPv4
];
const cfIp = req.headers["cf-connecting-ip"];
const forwardedIp = req.headers["x-forwarded-for"];
const userAgent = req.headers["user-agent"];
const clientIp = cfIp || forwardedIp || req.ip;
console.log("🔐 Incoming IP:", clientIp);
console.log("🧭 User-Agent:", userAgent);
if (trustedIps.includes(clientIp)) {
return next(); // Skip API key check for trusted IPs
}
const apiKey = req.headers["api-key"];
const authHeader = req.headers["authorization"];