28 lines
794 B
TypeScript
28 lines
794 B
TypeScript
export async function GET(req: Request) {
|
|
const url = new URL(req.url);
|
|
const res = await fetch(`http://localhost:3051/api/rules${url.search}`);
|
|
const body = await res.text();
|
|
return new Response(body, {
|
|
status: res.status,
|
|
headers: {
|
|
"Content-Type": res.headers.get("content-type") ?? "application/json"
|
|
}
|
|
});
|
|
}
|
|
|
|
export async function POST(req: Request) {
|
|
const body = await req.text();
|
|
const res = await fetch("http://localhost:3051/api/rules", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body
|
|
});
|
|
const payload = await res.text();
|
|
return new Response(payload, {
|
|
status: res.status,
|
|
headers: {
|
|
"Content-Type": res.headers.get("content-type") ?? "application/json"
|
|
}
|
|
});
|
|
}
|