30 lines
638 B
TypeScript
30 lines
638 B
TypeScript
const BACKEND_URL = process.env.BACKEND_URL;
|
|
|
|
export async function GET() {
|
|
const response = await fetch(`${BACKEND_URL}/users`);
|
|
|
|
if (!response.ok) {
|
|
return new Response("Request failed in backend", {
|
|
status: response.status,
|
|
});
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
return Response.json(data);
|
|
}
|
|
|
|
export async function POST(request: Request) {
|
|
const response = await fetch(`${BACKEND_URL}/users`, {
|
|
method: "POST",
|
|
headers: request.headers,
|
|
body: request.body,
|
|
duplex: "half",
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
return Response.json(data, {
|
|
status: response.status,
|
|
});
|
|
}
|