Hello, I’m using Next.js 14.2.3 with the app router, and I decided to add an API to my project. It worked fine locally, but when I deployed it to Vercel, it returned the default Next.js 404 page.
I created the API route at src/api/test/route.ts
with the following code for testing:
export const dynamic = 'force-dynamic';
import { NextRequest, NextResponse } from "next/server";
export async function GET(request: NextRequest) {
return NextResponse.json({ message: "Test" }, { status: 200 })
}
Current versus Expected Behavior
- Current Behavior: The API route returns a 404 error on Vercel.
- Expected Behavior: The API route should return a JSON response with the message “Test”.