fix: Remove build-time API calls to prevent timeouts
Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled

This commit is contained in:
2025-12-13 21:49:20 +01:00
parent 2236908701
commit a56e4c7a8a
2 changed files with 61 additions and 50 deletions

View File

@ -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<MetadataRoute.Sitemap> {
// 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<MetadataRoute.Sitemap> {
},
]
// 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 => ({
// 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]
}

View File

@ -15,21 +15,9 @@ interface TldData {
registry?: string | null
}
async function getTldData(tld: string): Promise<TldData | null> {
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