fix(build): extract FAVICON_SERVICE_URL to prevent server-side createContext error

The share/[id] layout is a server component that imported FAVICON_SERVICE_URL
from icons.tsx, pulling in the entire React icon registry and triggering
createContext on the server. Moved the constant to its own favicon.ts module.
This commit is contained in:
Usman Baig
2026-03-23 13:29:53 +01:00
parent 75bf8acd1e
commit 55a08301f4
6 changed files with 14 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
import type { Metadata } from 'next' import type { Metadata } from 'next'
import { FAVICON_SERVICE_URL } from '@/lib/utils/icons' import { FAVICON_SERVICE_URL } from '@/lib/utils/favicon'
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8082' const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8082'

View File

@@ -16,7 +16,7 @@ import TechSpecs from '@/components/dashboard/TechSpecs'
import { Select, DatePicker as DatePickerModal, Captcha, DownloadIcon, ZapIcon } from '@ciphera-net/ui' import { Select, DatePicker as DatePickerModal, Captcha, DownloadIcon, ZapIcon } from '@ciphera-net/ui'
import { DashboardSkeleton, useMinimumLoading, useSkeletonFade } from '@/components/skeletons' import { DashboardSkeleton, useMinimumLoading, useSkeletonFade } from '@/components/skeletons'
import ExportModal from '@/components/dashboard/ExportModal' import ExportModal from '@/components/dashboard/ExportModal'
import { FAVICON_SERVICE_URL } from '@/lib/utils/icons' import { FAVICON_SERVICE_URL } from '@/lib/utils/favicon'
// Helper to get date ranges // Helper to get date ranges
const getDateRange = (days: number) => { const getDateRange = (days: number) => {

View File

@@ -9,7 +9,7 @@ import { useSettingsModal } from '@/lib/settings-modal-context'
import { getUserOrganizations, switchContext, type OrganizationMember } from '@/lib/api/organization' import { getUserOrganizations, switchContext, type OrganizationMember } from '@/lib/api/organization'
import { setSessionAction } from '@/app/actions/auth' import { setSessionAction } from '@/app/actions/auth'
import { logger } from '@/lib/utils/logger' import { logger } from '@/lib/utils/logger'
import { FAVICON_SERVICE_URL } from '@/lib/utils/icons' import { FAVICON_SERVICE_URL } from '@/lib/utils/favicon'
import { Gauge as GaugeIcon } from '@phosphor-icons/react' import { Gauge as GaugeIcon } from '@phosphor-icons/react'
import { import {
LayoutDashboardIcon, LayoutDashboardIcon,

View File

@@ -7,7 +7,7 @@ import type { Stats } from '@/lib/api/stats'
import { formatNumber } from '@ciphera-net/ui' import { formatNumber } from '@ciphera-net/ui'
import { BarChartIcon, SettingsIcon, BookOpenIcon, ExternalLinkIcon, Button } from '@ciphera-net/ui' import { BarChartIcon, SettingsIcon, BookOpenIcon, ExternalLinkIcon, Button } from '@ciphera-net/ui'
import { useAuth } from '@/lib/auth/context' import { useAuth } from '@/lib/auth/context'
import { FAVICON_SERVICE_URL } from '@/lib/utils/icons' import { FAVICON_SERVICE_URL } from '@/lib/utils/favicon'
export type SiteStatsMap = Record<string, { stats: Stats }> export type SiteStatsMap = Record<string, { stats: Stats }>

8
lib/utils/favicon.ts Normal file
View File

@@ -0,0 +1,8 @@
/**
* Google's public favicon service base URL.
* Append `?domain=<host>&sz=<px>` to get a favicon.
*
* Kept in a separate module so server components can import it
* without pulling in the React-dependent icon registry.
*/
export const FAVICON_SERVICE_URL = 'https://www.google.com/s2/favicons'

View File

@@ -43,11 +43,8 @@ function BingIcon({ size = 16, color = '#258FFA' }: { size?: number; color?: str
return <svg width={size} height={size} viewBox="0 0 24 24" fill={color}><path d="M5.71 0v18.39l4.44 2.46 8.14-4.69v-4.71l-8.14-2.84V4.09L5.71 0zm4.44 11.19l4.39 1.53v2.78l-4.39 2.53v-6.84z"/></svg> return <svg width={size} height={size} viewBox="0 0 24 24" fill={color}><path d="M5.71 0v18.39l4.44 2.46 8.14-4.69v-4.71l-8.14-2.84V4.09L5.71 0zm4.44 11.19l4.39 1.53v2.78l-4.39 2.53v-6.84z"/></svg>
} }
/** import { FAVICON_SERVICE_URL } from './favicon'
* Google's public favicon service base URL. export { FAVICON_SERVICE_URL }
* Append `?domain=<host>&sz=<px>` to get a favicon.
*/
export const FAVICON_SERVICE_URL = 'https://www.google.com/s2/favicons'
// ─── Browser, OS, Device icons (unchanged) ─────────────────────────────────── // ─── Browser, OS, Device icons (unchanged) ───────────────────────────────────