Next.js Discord

Discord Forum

[Issue] NextJS 13.4.12 keep treating api route handler as pages!

Unanswered
Crazy ant posted this in #help-forum
Open in Discord
Crazy antOP
the error is ReferenceError: hasProp is not defined.

at the end showing it cannot collect page data /api/crawl. my route.js is like this:

import { NextResponse } from "next/server";

export async function POST(request) {
  const { target } = await request.json();
  .... // all my logic
  return NextResponse.json(data, { status: 201 });
}


it works just fine in dev, but this error only comes in build.

2 Replies

It is likely caused by the critical dependency error above, the seenreq library required by crawler has problems that makes the build failed.

I had fixed similar errors by adding this to next config:
experimental: {
      serverComponentsExternalPackages: ['crawler'], // the name of dependency 
}
Crazy antOP
that config would fix it or not?

edit: yup it does, thanks, hopefully i could remember in the future