Next.js Discord

Discord Forum

Why is my API considered static in Next.js 14?

Unanswered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
I created this GET API using Next.js 14, but in production, Next.js treats it as static. I'd like to know why this is happening and how I could resolve it. Thank you!
import {db} from "@/lib/db";

export async function GET(req: Request) {
  try {
    const {searchParams} = new URL(req.url);
    ...
  } catch (error) {
    return new Response(null, 500);
  }

2 Replies

American Crow
@American Crow https://nextjs.org/docs/app/building-your-application/routing/route-handlers#behavior
Asiatic LionOP
Okay, but in the API, I'm already using the Request object to get the URL