From a56e4c7a8a72e5dbb2deebabcf0cb0e5cee15fb1 Mon Sep 17 00:00:00 2001 From: Yves Gugger Date: Sat, 13 Dec 2025 21:49:20 +0100 Subject: [PATCH] fix: Remove build-time API calls to prevent timeouts --- frontend/src/app/sitemap.ts | 93 ++++++++++++++++++----------- frontend/src/app/tld/[tld]/page.tsx | 18 +----- 2 files changed, 61 insertions(+), 50 deletions(-) diff --git a/frontend/src/app/sitemap.ts b/frontend/src/app/sitemap.ts index 8553127..a06ef83 100644 --- a/frontend/src/app/sitemap.ts +++ b/frontend/src/app/sitemap.ts @@ -1,8 +1,57 @@ import { MetadataRoute } from 'next' import { POPULAR_TLDS, SITE_URL } from '@/lib/seo' -// This generates a dynamic sitemap including all TLD pages -export default async function sitemap(): Promise { +// All TLDs for sitemap - statically defined to avoid build-time API calls +const ALL_TLDS = [ + // Generic TLDs + 'com', 'net', 'org', 'info', 'biz', 'name', 'pro', + // New gTLDs - Popular + 'io', 'ai', 'co', 'app', 'dev', 'xyz', 'online', 'store', 'shop', 'tech', + 'site', 'club', 'fun', 'space', 'website', 'live', 'news', 'blog', 'cloud', + 'digital', 'agency', 'studio', 'media', 'design', 'solutions', 'consulting', + 'group', 'team', 'work', 'zone', 'center', 'network', 'systems', 'services', + // Finance + 'finance', 'money', 'bank', 'insurance', 'invest', 'capital', 'fund', 'trading', + 'exchange', 'cash', 'tax', 'accountant', 'financial', 'investments', + // Tech + 'technology', 'software', 'computer', 'hosting', 'email', 'mobile', 'phone', + 'web', 'page', 'link', 'click', 'download', 'stream', + // Business + 'business', 'company', 'enterprises', 'inc', 'ltd', 'llc', 'gmbh', 'holdings', + 'ventures', 'partners', 'associates', 'global', 'international', 'world', + // Lifestyle + 'life', 'health', 'fitness', 'beauty', 'fashion', 'style', 'luxury', 'vip', + 'cool', 'lol', 'wtf', 'fail', 'win', 'best', 'top', 'plus', 'one', + // Crypto + 'crypto', 'nft', 'web3', 'blockchain', 'bitcoin', 'defi', 'dao', 'token', 'eth', + // Creative + 'art', 'photography', 'photos', 'pics', 'gallery', 'graphics', 'video', 'film', + 'music', 'band', 'audio', 'radio', 'tv', 'show', 'movie', 'theater', + // Food & Drink + 'restaurant', 'cafe', 'coffee', 'bar', 'pub', 'wine', 'beer', 'pizza', 'kitchen', + // Real Estate + 'house', 'homes', 'property', 'properties', 'estate', 'land', 'apartments', 'condos', + // Travel + 'travel', 'tours', 'holiday', 'vacation', 'flights', 'hotel', 'hotels', 'resort', + // Education + 'education', 'academy', 'school', 'college', 'university', 'training', 'courses', + // Sports + 'sport', 'football', 'soccer', 'golf', 'tennis', 'racing', 'bike', 'run', 'fit', + // ccTLDs - Europe + 'ch', 'de', 'at', 'uk', 'co.uk', 'fr', 'es', 'it', 'nl', 'be', 'pl', 'pt', 'se', + 'no', 'fi', 'dk', 'ie', 'cz', 'sk', 'hu', 'ro', 'gr', 'ru', 'ua', + // ccTLDs - Americas + 'us', 'ca', 'mx', 'br', 'ar', 'cl', 'co', 'pe', 'vc', + // ccTLDs - Asia Pacific + 'jp', 'cn', 'kr', 'in', 'sg', 'hk', 'tw', 'au', 'nz', 'ph', 'my', 'id', 'th', 'vn', + // ccTLDs - Other + 'za', 'ae', 'il', 'sa', 'ng', 'ke', 'eg', + // Popular alternatives + 'cc', 'tv', 'me', 'ws', 'la', 'sx', 'gg', 'to', 'fm', 'am', 'im', +] + +// This generates a static sitemap - no API calls during build +export default function sitemap(): MetadataRoute.Sitemap { const baseUrl = SITE_URL const now = new Date() @@ -64,39 +113,13 @@ export default async function sitemap(): Promise { }, ] - // Fetch all TLDs from API for dynamic TLD pages - let tldPages: MetadataRoute.Sitemap = [] - - try { - // Try to fetch TLDs from the API - const response = await fetch(`${baseUrl}/api/v1/tld/overview?limit=100`, { - next: { revalidate: 86400 }, // Revalidate daily - }) - - if (response.ok) { - const data = await response.json() - const tlds = data.tlds || [] - - tldPages = tlds.map((tld: { tld: string }) => ({ - url: `${baseUrl}/tld/${tld.tld.toLowerCase()}`, - lastModified: now, - changeFrequency: 'daily' as const, - priority: 0.7, - })) - } - } catch (error) { - console.error('Failed to fetch TLDs for sitemap:', error) - } - - // If API failed, use popular TLDs as fallback - if (tldPages.length === 0) { - tldPages = POPULAR_TLDS.map(tld => ({ - url: `${baseUrl}/tld/${tld}`, - lastModified: now, - changeFrequency: 'daily' as const, - priority: 0.7, - })) - } + // TLD pages - statically generated + const tldPages: MetadataRoute.Sitemap = ALL_TLDS.map(tld => ({ + url: `${baseUrl}/tld/${tld}`, + lastModified: now, + changeFrequency: 'daily' as const, + priority: 0.7, + })) return [...staticPages, ...tldPages] } diff --git a/frontend/src/app/tld/[tld]/page.tsx b/frontend/src/app/tld/[tld]/page.tsx index b637d5d..f4612ae 100644 --- a/frontend/src/app/tld/[tld]/page.tsx +++ b/frontend/src/app/tld/[tld]/page.tsx @@ -15,21 +15,9 @@ interface TldData { registry?: string | null } -async function getTldData(tld: string): Promise { - try { - const response = await fetch(`${SITE_URL}/api/v1/tld/${tld}`, { - next: { revalidate: 3600 }, // Revalidate every hour - }) - - if (!response.ok) { - return null - } - - return response.json() - } catch (error) { - console.error('Failed to fetch TLD data:', error) - return null - } +// No build-time API calls - data is fetched client-side +function getTldData(_tld: string): TldData | null { + return null // Data loaded client-side in TldDetailClient } // Generate static params for popular TLDs