NeahNew/app/api/nextcloud/init/route.ts
2025-05-04 13:45:45 +02:00

30 lines
1.0 KiB
TypeScript

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
// init endpoint to the new MinIO S3 init endpoint
export async function POST(request: Request) {
try {
// Get session
const session = await getServerSession(authOptions);
if (!session?.user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// Forward the request to the new endpoint
const response = await fetch('/api/storage/init', {
method: 'POST',
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 init adapter:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}