NeahNew/app/api/nextcloud/files/content/route.ts
2025-05-05 13:04:01 +02:00

28 lines
1.1 KiB
TypeScript

import { NextResponse } from 'next/server';
import { getServerSession } from 'next-auth';
import { authOptions } from "@/app/api/auth/options";
// This file serves as an adapter to redirect requests from the old NextCloud
// content endpoint to the new MinIO S3 content 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 });
}
// Forward to storage handler
try {
const { GET: storageContentHandler } = await import('@/app/api/storage/files/content/route');
return await storageContentHandler(request);
} catch (error) {
console.error('Error calling storage content handler:', error);
return NextResponse.json({ error: 'Failed to get file content' }, { status: 500 });
}
} catch (error) {
console.error('Error in NextCloud content adapter:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}