const EXCLUDED_PATHS = [ '/api/auth/oauth/vk/callback', '/api/auth/oauth/yandex/callback', '/api/webhooks/yookassa', '/api/admin/notifications/telegram/webhook', ] function normalizeIp(ip) { if (ip && ip.startsWith('::ffff:')) { return ip.slice(7) } return ip } export function build403Html(ip) { const safeIp = ip || 'не определён' return ` Любимый Креатив

Любимый Креатив

Изделия ручной работы: вещи с характером и вниманием к деталям

Сайт находится в разработке и скоро будет доступен

Ваш IP: ${safeIp}

` } export async function registerIpGate(fastify) { fastify.addHook('onRequest', async (request, reply) => { const allowed = process.env.SITE_ACCESS_IPS if (!allowed) return const allowedIps = allowed .split(',') .map((s) => normalizeIp(s.trim())) .filter(Boolean) if (allowedIps.length === 0) return const urlPath = request.url.split('?')[0] if (EXCLUDED_PATHS.includes(urlPath)) return if (allowedIps.includes(normalizeIp(request.ip))) return return reply.code(403).type('text/html').send(build403Html(request.ip)) }) }