diff --git a/app/[lang]/page.tsx b/app/[lang]/page.tsx index efb4f4b..7ea1bd1 100644 --- a/app/[lang]/page.tsx +++ b/app/[lang]/page.tsx @@ -22,7 +22,7 @@ async function getInstagramData() { username: 'moy_akyaka', maxId: '' }), - next: { revalidate: 86400 } // 24 hours + next: { revalidate: 3600 } // 1 hour to prevent CDN link expiration }); if (!res.ok) { diff --git a/app/api/instagram-proxy/route.ts b/app/api/instagram-proxy/route.ts new file mode 100644 index 0000000..f36a814 --- /dev/null +++ b/app/api/instagram-proxy/route.ts @@ -0,0 +1,34 @@ +import { NextRequest, NextResponse } from 'next/server'; + +export async function GET(request: NextRequest) { + const url = request.nextUrl.searchParams.get('url'); + + if (!url) { + return new NextResponse('Missing url parameter', { status: 400 }); + } + + try { + const res = await fetch(url, { + headers: { + // Use a generic user agent + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', + } + }); + + if (!res.ok) { + console.error('Failed to proxy instagram image:', res.status, res.statusText); + return new NextResponse('Failed to fetch image', { status: res.status }); + } + + const buffer = await res.arrayBuffer(); + + const headers = new Headers(); + headers.set('Content-Type', res.headers.get('Content-Type') || 'image/jpeg'); + headers.set('Cache-Control', 'public, max-age=86400, s-maxage=86400'); + + return new NextResponse(buffer, { headers }); + } catch (error) { + console.error('Error in instagram proxy:', error); + return new NextResponse('Error fetching image', { status: 500 }); + } +} diff --git a/components/InstagramFeed.tsx b/components/InstagramFeed.tsx index 9d385a7..91cb66f 100644 --- a/components/InstagramFeed.tsx +++ b/components/InstagramFeed.tsx @@ -62,7 +62,7 @@ export default function InstagramFeed({ dict, posts = [] }: { dict: any, posts?: