// Trigger frontend cache revalidation (fire-and-forget)
// Revalidates both the sitemap and the next-event data (homepage, llms.txt)
export function revalidateFrontendCache() {
  const frontendUrl = process.env.FRONTEND_URL || 'http://localhost:3002';
  const secret = process.env.REVALIDATE_SECRET;
  if (!secret) {
    console.warn('REVALIDATE_SECRET not set, skipping frontend revalidation');
    return;
  }
  fetch(`${frontendUrl}/api/revalidate`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ secret, tag: ['events-sitemap', 'next-event'] }),
  })
    .then((res) => {
      if (!res.ok) console.error('Frontend revalidation failed:', res.status);
      else console.log('Frontend revalidation triggered (sitemap + next-event)');
    })
    .catch((err) => {
      console.error('Frontend revalidation error:', err.message);
    });
}
