|
|
@@ -1,22 +1,30 @@
|
|
|
import { NextRequest } from 'next/server';
|
|
|
|
|
|
-// This is a WebSocket endpoint for real-time import progress updates
|
|
|
+// This endpoint provides import progress updates
|
|
|
export async function GET(
|
|
|
request: NextRequest,
|
|
|
- { params }: { params: { id: string } }
|
|
|
+ { params }: { params: Promise<{ id: string }> }
|
|
|
) {
|
|
|
- // This will be handled by the WebSocket upgrade
|
|
|
- return new Response('WebSocket endpoint for import progress', { status: 101 });
|
|
|
+ const { id: importId } = await params;
|
|
|
+
|
|
|
+ // Return current progress as JSON for polling fallback
|
|
|
+ return Response.json({
|
|
|
+ importId,
|
|
|
+ status: 'processing',
|
|
|
+ progress: 0,
|
|
|
+ message: 'Import in progress...',
|
|
|
+ timestamp: new Date().toISOString()
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
-// WebSocket upgrade handler
|
|
|
-export async function upgradeWebSocket(
|
|
|
- request: NextRequest,
|
|
|
- { params }: { params: { id: string } }
|
|
|
-) {
|
|
|
- const importId = parseInt(params.id);
|
|
|
-
|
|
|
- // This would typically be handled by a custom server setup
|
|
|
- // For now, we'll use the standalone WebSocket server
|
|
|
- return new Response(null, { status: 101 });
|
|
|
+// Handle CORS preflight requests
|
|
|
+export async function OPTIONS() {
|
|
|
+ return new Response(null, {
|
|
|
+ status: 204,
|
|
|
+ headers: {
|
|
|
+ 'Access-Control-Allow-Origin': '*',
|
|
|
+ 'Access-Control-Allow-Methods': 'GET, OPTIONS',
|
|
|
+ 'Access-Control-Allow-Headers': 'Content-Type, Authorization',
|
|
|
+ },
|
|
|
+ });
|
|
|
}
|