ajout du fichier de route
This commit is contained in:
parent
c851865728
commit
ef1ba911d9
4 changed files with 125 additions and 27 deletions
26
frontend/app/api/contact/route.ts
Normal file
26
frontend/app/api/contact/route.ts
Normal 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 });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue