debug: add logging to home page endpoint and debug route
This commit is contained in:
@@ -35,10 +35,17 @@ export async function GET(request: NextRequest) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const locale = searchParams.get('locale') || 'pt';
|
||||
|
||||
console.log(`[API PAGES HOME] GET locale=${locale}`);
|
||||
|
||||
const page = await prisma.pageContent.findUnique({
|
||||
where: { slug_locale: { slug: 'home', locale } }
|
||||
});
|
||||
|
||||
console.log(`[API PAGES HOME] Encontrado:`, page ? 'SIM' : 'NÃO');
|
||||
if (page) {
|
||||
console.log(`[API PAGES HOME] Conteúdo:`, JSON.stringify(page.content, null, 2));
|
||||
}
|
||||
|
||||
if (!page) {
|
||||
// Retornar página padrão vazia
|
||||
return NextResponse.json({
|
||||
@@ -91,6 +98,8 @@ export async function POST(request: NextRequest) {
|
||||
? JSON.parse(body.content)
|
||||
: body.content;
|
||||
|
||||
console.log('[API PAGES HOME] POST - Salvando conteúdo:', JSON.stringify(content, null, 2));
|
||||
|
||||
const page = await prisma.pageContent.upsert({
|
||||
where: { slug_locale: { slug: 'home', locale } },
|
||||
update: { content },
|
||||
@@ -101,6 +110,8 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[API PAGES HOME] POST - Salvo com sucesso');
|
||||
|
||||
return NextResponse.json({ success: true, page });
|
||||
} catch (error) {
|
||||
console.error('Erro ao salvar página home:', error);
|
||||
@@ -134,6 +145,8 @@ export async function PUT(request: NextRequest) {
|
||||
? JSON.parse(body.content)
|
||||
: body.content;
|
||||
|
||||
console.log('[API PAGES HOME] PUT - Atualizando conteúdo:', JSON.stringify(content, null, 2));
|
||||
|
||||
const page = await prisma.pageContent.upsert({
|
||||
where: { slug_locale: { slug: 'home', locale } },
|
||||
update: { content },
|
||||
@@ -144,6 +157,8 @@ export async function PUT(request: NextRequest) {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[API PAGES HOME] PUT - Atualizado com sucesso');
|
||||
|
||||
return NextResponse.json({ success: true, page });
|
||||
} catch (error) {
|
||||
console.error('Erro ao atualizar página home:', error);
|
||||
|
||||
Reference in New Issue
Block a user