diff --git a/app/files/[...path]/route.js b/app/files/[...path]/route.js index 00d001c..b43796f 100644 --- a/app/files/[...path]/route.js +++ b/app/files/[...path]/route.js @@ -40,14 +40,14 @@ export async function GET(req, { params }) { const data = fs.readFileSync(localPath); return new NextResponse(data, { status: 200, - headers: { 'Content-Type': getContentType(localPath) } + headers: { 'Content-Type': getContentType(localPath), 'Cache-Control': 'public, max-age=31536000, immutable' } }); } const remoteUrl = `${BACKEND_SERVER_URL}/files/${fileName}`; const res = await fetch(remoteUrl); if (!res.ok) { - return new NextResponse('Not Found', { status: 404 }); + return new NextResponse('Not Found', { status: 404, headers: { 'Cache-Control': 'no-store' } }); } const arrayBuffer = await res.arrayBuffer(); const buffer = Buffer.from(arrayBuffer); @@ -58,10 +58,10 @@ export async function GET(req, { params }) { return new NextResponse(buffer, { status: 200, - headers: { 'Content-Type': getContentType(localPath) } + headers: { 'Content-Type': getContentType(localPath), 'Cache-Control': 'public, max-age=31536000, immutable' } }); } catch (e) { - return new NextResponse('Server Error', { status: 500 }); + return new NextResponse('Server Error', { status: 500, headers: { 'Cache-Control': 'no-store' } }); } } diff --git a/components/products/ProductImageGallery.jsx b/components/products/ProductImageGallery.jsx index cb466d7..9115d0e 100644 --- a/components/products/ProductImageGallery.jsx +++ b/components/products/ProductImageGallery.jsx @@ -10,6 +10,37 @@ import "swiper/css/pagination"; import "swiper/css/thumbs"; import "swiper/css/free-mode"; +const ImageWithRetry = ({ src, alt, className }) => { + const [imageSrc, setImageSrc] = useState(src); + const retryCountRef = useRef(0); + + useEffect(() => { + setImageSrc(src); + retryCountRef.current = 0; + }, [src]); + + const handleError = useCallback(() => { + if (retryCountRef.current >= 3) return; + retryCountRef.current += 1; + const delay = 300 * retryCountRef.current; + setTimeout(() => { + const url = new URL(imageSrc, typeof window !== 'undefined' ? window.location.origin : 'http://localhost'); + url.searchParams.set('v', String(Date.now())); + setImageSrc(url.pathname + url.search); + }, delay); + }, [imageSrc]); + + return ( + {alt} + ); +}; + const ProductImageGallery = ({ data }) => { const [currentImageIndex, setCurrentImageIndex] = useState(0); const [thumbsSwiper, setThumbsSwiper] = useState(null); @@ -136,14 +167,10 @@ const ProductImageGallery = ({ data }) => { } }} > - {`${data?.title { - e.target.style.display = 'none'; - }} />
@@ -157,11 +184,10 @@ const ProductImageGallery = ({ data }) => {
- {data?.title {data.attachments.length > 1 && ( diff --git a/public/sitemap.xml b/public/sitemap.xml index 402dcc9..b506531 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -21,6 +21,11 @@ weekly 0.7 + + http://192.168.2.200:3001/products/crossbody-bags/chic-leather-crossbody-bag-7 + weekly + 0.7 + http://192.168.2.200:3001/products/fashion-handbags/chic-leather-crossbody-bag-2 weekly @@ -66,6 +71,11 @@ weekly 0.7 + + http://192.168.2.200:3001/products/crossbody-bags/elegant-leather-crossbody-bag-6 + weekly + 0.7 + http://192.168.2.200:3001/products/fashion-handbags/chic-leather-crossbody-bag-3 weekly