Fix API routing using Next.js proxy
Browse files
frontend/app/api/run-systemforge/route.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { NextRequest, NextResponse } from "next/server";
|
| 2 |
+
|
| 3 |
+
export async function POST(req: NextRequest) {
|
| 4 |
+
try {
|
| 5 |
+
const body = await req.json();
|
| 6 |
+
|
| 7 |
+
const response = await fetch(
|
| 8 |
+
"http://127.0.0.1:8000/run-systemforge",
|
| 9 |
+
{
|
| 10 |
+
method: "POST",
|
| 11 |
+
headers: {
|
| 12 |
+
"Content-Type": "application/json",
|
| 13 |
+
},
|
| 14 |
+
body: JSON.stringify(body),
|
| 15 |
+
}
|
| 16 |
+
);
|
| 17 |
+
|
| 18 |
+
const data = await response.json();
|
| 19 |
+
|
| 20 |
+
return NextResponse.json(data, {
|
| 21 |
+
status: response.status,
|
| 22 |
+
});
|
| 23 |
+
} catch (error) {
|
| 24 |
+
return NextResponse.json(
|
| 25 |
+
{
|
| 26 |
+
error: "Internal server error",
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
status: 500,
|
| 30 |
+
}
|
| 31 |
+
);
|
| 32 |
+
}
|
| 33 |
+
}
|
frontend/lib/api.ts
CHANGED
|
@@ -9,7 +9,7 @@ export async function generateWorkflowRedesign(
|
|
| 9 |
console.log("API_URL =", API_URL);
|
| 10 |
|
| 11 |
const response = await fetch(
|
| 12 |
-
`
|
| 13 |
{
|
| 14 |
method: "POST",
|
| 15 |
headers: {
|
|
@@ -42,7 +42,7 @@ export async function downloadArchitectureReport(
|
|
| 42 |
process.env.NEXT_PUBLIC_API_URL || "";
|
| 43 |
|
| 44 |
const response = await fetch(
|
| 45 |
-
`
|
| 46 |
{
|
| 47 |
method: "POST",
|
| 48 |
headers: {
|
|
|
|
| 9 |
console.log("API_URL =", API_URL);
|
| 10 |
|
| 11 |
const response = await fetch(
|
| 12 |
+
`/api/run-systemforge`,
|
| 13 |
{
|
| 14 |
method: "POST",
|
| 15 |
headers: {
|
|
|
|
| 42 |
process.env.NEXT_PUBLIC_API_URL || "";
|
| 43 |
|
| 44 |
const response = await fetch(
|
| 45 |
+
`/api/download-report`,
|
| 46 |
{
|
| 47 |
method: "POST",
|
| 48 |
headers: {
|