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 response = await fetch(`${baseUrl}/api/schoolforschools?populate=*`, {
            method: 'GET',
            headers: {
                'Content-Type': 'application/json',
            },
            next: { revalidate: 300 } // Cache for 5 minutes
        })

        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`)
        }

        const json = await response.json()
        
        return NextResponse.json(json, {
            headers: {
                'Cache-Control': 'public, s-maxage=300, stale-while-revalidate=600',
            },
        })
    } catch (error) {
        console.error('Error fetching main hero content:', error)
        return NextResponse.json({ error: 'Failed to fetch content' }, { status: 500 })
    }
}

