Build Failed on Next.js 15.2.3 App Router - "invalid GET export" in API route

Hello, community!
I need help with a persistent build error in my Next.js 15.2.3 project. The build failed on Netlify, but works perfectly in my local development environment.
Thank you for your help!

Brunx Dashboard
**dashing-sawine-0767a2.netlify.app
**

Problem Description
The build is failing with a specific Type error in an API route handler. Next.js is rejecting the GET function signature, even though it conforms to the App Router standard syntax. I’ve tried several code fixes, but the error persists.
Diagnosis: The build failed due to a type error in the file src/app/api/products/[productId]/route.ts at line 86. The error states that the type { params: { productId: string; }; } is not a valid type for the function’s second argument.

Solution: To resolve this issue:

  1. Verify that the type { params: { productId: string; }; } is correctly defined for the function’s second argument in the route.ts file.

  2. Ensure that the types and arguments match correctly in the function definitions within the file.

After addressing the type error, you can push the changes to the repository and trigger a new build to verify if the issue is resolved.

Build Logs and Configurations
Here are the full Netlify build logs and configurations.

Logs:
▲ Next.js 15.2.3

1:13:42 PM: Creating an optimized production build …

1:13:56 PM: Compiled successfully

1:13:56 PM: Linting and checking validity of types …

1:14:01 PM: Failed to compile.

1:14:01 PM:

1:14:01 PM: src/app/api/products/[productId]/route.ts

1:14:01 PM: Type error: Route “src/app/api/products/[productId]/route.ts” has an invalid “GET” export:

1:14:01 PM: Type “{ params: { productId: string; }; }” is not a valid type for the function’s second argument.

1:14:01 PM: Next.js build worker exited with code: 1 and signal: null

1:14:02 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)

1:14:02 PM:

1:14:02 PM: “build.command” failed

Build Settings:

Build Command: npm run build

Publish Directory: out

Next.js Version: 15.2.3

Node.js Version: 20.15.0 (set via the NODE_VERSION environment variable)

Specific Error Details:

src/app/api/products/[productId]/route.ts

Type error: Route “src/app/api/products/[productId]/route.ts” has an invalid “GET” export:

Type “{ params: { productId: string; }; }” is not a valid type for the function’s second argument.

Attempted Solutions
I’ve already investigated this issue and tried the following fixes:

I fixed typing errors and ESLint warnings, such as “Unexpected any.”

I adjusted the GET function syntax for different variations ({params}, context, etc.) to try to bypass type validation.

I performed a cache-free deployment to ensure all dependencies were installed from scratch.

Did you try to run next build locally?

yes, but i received that error :

Sounds like an issue with your project then, not Netlify. Please ask on Next.js forums.

1 Like