SFS/app/api/logo/route.ts
2025-12-16 10:03:26 +05:30

32 lines
992 B
TypeScript

import { NextResponse } from 'next/server'
export async function GET() {
try {
const strapiBaseUrl = process.env.NEXT_PUBLIC_STRAPI_BASE_URL || process.env.NEW_STRAPI_URL || "http://160.187.167.213"
const baseUrl = strapiBaseUrl.replace(/\/+$/, "")
const res = await fetch(`${baseUrl}/api/logo?populate=*`, {
headers: {
Accept: "application/json",
},
next: { revalidate: 300 } // Cache for 5 minutes
})
if (!res.ok) {
throw new Error(`Strapi logo status ${res.status}`)
}
const json = await res.json()
return NextResponse.json(json, {
headers: {
'Cache-Control': 'public, s-maxage=300, stale-while-revalidate=600',
},
})
} catch (error) {
console.error('Error fetching logo:', error)
return NextResponse.json({ error: 'Failed to fetch logo' }, { status: 500 })
}
}