const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001'; export interface DomainCheckResult { tld: string; fqdn: string; status: 'available' | 'registered'; primary: boolean; } export interface DomainCheckResponse { domain: string; results: DomainCheckResult[]; } export async function checkDomainAction( domain: string, ): Promise { const response = await fetch(`${API_URL}/modules/domaincheck/check`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ domain }), credentials: 'include', }); if (!response.ok) { const errorBody = await response.text().catch(() => ''); throw new Error( `Domain check failed: ${response.status} ${errorBody}`.trim(), ); } return response.json(); }