import { NextResponse } from 'next/server'; import { getServerSession } from 'next-auth'; import { authOptions } from '@/app/api/auth/[...nextauth]/route'; // This file serves as an adapter to redirect requests from the old NextCloud // status endpoint to the new MinIO S3 status endpoint export async function GET(request: Request) { try { // Get session const session = await getServerSession(authOptions); if (!session?.user) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } // Get the base URL from the request const { protocol, host } = new URL(request.url); const baseUrl = `${protocol}//${host}`; // Forward the request to the new endpoint const response = await fetch(`${baseUrl}/api/storage/status`, { headers: { 'Cookie': request.headers.get('cookie') || '' } }); // Return the response from the new endpoint return NextResponse.json(await response.json(), { status: response.status }); } catch (error) { console.error('Error in NextCloud status adapter:', error); return NextResponse.json({ error: 'Internal server error' }, { status: 500 }); } }