ajout du fichier de route

This commit is contained in:
mrtoine 2025-10-01 14:42:59 +02:00
parent c851865728
commit ef1ba911d9
4 changed files with 125 additions and 27 deletions

View file

@ -0,0 +1,26 @@
import { NextResponse } from "next/server";
export async function GET() {
try {
const baseUrl = process.env.BACKEND_URL;
if (!baseUrl) {
return NextResponse.json({ error: "BACKEND_URL not configured" }, { status: 500 });
}
const url = `${baseUrl.replace(/\/$/, "")}/contact`;
const res = await fetch(url, { cache: "no-store" });
if (!res.ok) {
return NextResponse.json({ error: "Failed to fetch contact data" }, { status: res.status });
}
const data = await res.json();
// Ensure we only expose expected fields
const { email, linkedin, github } = data || {};
return NextResponse.json({ email, linkedin, github }, { status: 200 });
} catch (error) {
return NextResponse.json({ error: "Unexpected error" }, { status: 500 });
}
}