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

3 messages · Page 1 of 1 (latest)

spiral verge
#

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.

small pythonBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

mental ore
#

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 
}