fix: resolve Next.js route conflict in microdao api

This commit is contained in:
Apple
2025-11-28 10:23:15 -08:00
parent c7924570c1
commit cbd5b2f731

View File

@@ -0,0 +1,45 @@
import { NextRequest, NextResponse } from 'next/server';
const CITY_API_URL = process.env.INTERNAL_API_URL || process.env.CITY_API_BASE_URL || 'http://daarion-city-service:7001';
/**
* PUT /api/microdao/[slug]/visibility
* Update MicroDAO visibility settings
* Note: [slug] here is actually microdaoId, but named slug to avoid Next.js route conflict
*/
export async function PUT(
request: NextRequest,
context: { params: Promise<{ slug: string }> }
) {
try {
const { slug: microdaoId } = await context.params;
const body = await request.json();
const response = await fetch(`${CITY_API_URL}/city/microdao/${microdaoId}/visibility`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
console.error('Failed to update microdao visibility:', response.status, text);
return NextResponse.json(
{ error: 'Failed to update MicroDAO visibility', detail: text },
{ status: response.status }
);
}
const data = await response.json();
return NextResponse.json(data);
} catch (error) {
console.error('Error updating microdao visibility:', error);
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
);
}
}