Next.js Discord

Discord Forum

vercel.json Issue

Unanswered
Boreal Chickadee posted this in #help-forum
Open in Discord
Boreal ChickadeeOP
Hello! I updated my vercel.json file for my my fastapi app based on vercel support on how to correctly set maxDuration and am now getting 404 errors. Any insight on what I am overlooking would be greatly appreciated.

Before;

{

"version": 2,

"builds": [{ "src": "chat.py", "use": "@vercel/python" }],

"routes": [{ "src": "/(.)", "dest": "chat.py" }],

"functions": {

"chat.py": {

"maxDuration": 200

}

}

}



After:

{
"routes": [
{
"src": "/.
",
"dest": "api/chat.py"
}
],

"functions": {
"api/chat.py": { "maxDuration": 200 }
}
}


route handler;

import { NextRequest, NextResponse } from "next/server";

export async function POST(request: NextRequest) {
try {
console.log("Received request:", request); // Log incoming request

// Forward the request to the Python backend
console.log("Forwarding request to backend");
const backendRes = await fetch(
"https://rooted-gpt-chat-script.vercel.app/api/message",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(await request.json()),
}
);

console.log("Received response from backend"); // Log backend response

if (!backendRes.ok) {
console.error("Error from backend:", backendRes.status); // Log backend error
throw new Error(Error from backend: ${backendRes.status});
}

// Get the response from the backend
const data = await backendRes.json();
console.log("Backend data:", data); // Log the data from backend

// Send the response back to the frontend
return NextResponse.json(data);
} catch (error) {
console.error("Request failed:", error); // Log error
return new NextResponse(
JSON.stringify({ message: "Internal Server Error" }),
{ status: 500 }
);
}
}

export const runtime = "edge";


script is attached. to the post

0 Replies