"use client"; import NextImage, { type ImageProps } from "next/image"; import { useState } from "react"; const CDN_ORIGIN = "https://buzz-cdn.astrxl.dev"; export default function ResilientImage({ src, unoptimized, onError, ...props }: ImageProps) { const [failedSource, setFailedSource] = useState(null); const useOriginal = typeof src === "string" && failedSource === src; return ( { if (!useOriginal && typeof src === "string" && src.startsWith(`${CDN_ORIGIN}/`)) { setFailedSource(src); } onError?.(event); }} /> ); }