Incorrect type in Next.js 15 GET API route during Netlify deploy or build

Issue Summary:

While npm run dev works, building (npm run build) or deploying on Netlify triggers a type error on the GET export for an API route.

Revised Example:

import { Request, Response } from 'next/server';
import { dbConnector } from './dbUtil';

export async function fetchData(req, { identifiers }) {
  try {
    const id = identifiers.id;
    const res = await dbConnector.query('SELECT * FROM logs WHERE log_id = $1', [id]);
    return Response.json({ data: res.rows });
  } catch (error) {
    return Response.json({ error: 'Error fetching logs' }, { status: 500 });
  }
}

In my experience, this issue often comes from differences in how development and production environments process type checking. When I encountered a similar error, I discovered that the GET function’s type definitions needed to match those expected by the build system. I ended up adjusting the function signature to better align with Next.js conventions and ensured that the parameter types were explicitly defined, thus preventing the mismatch during device compilations. Once the type definitions were made more explicit and compliant with the strict rules observed during the build, I was able to successfully deploy on Netlify.