I have a Vercel function in my NextJS application located at app\api\products\route.ts which exposes a GET endpoint as shown in the blow code. Everytime I do a deployment, Vercel is invoking the GET endpoint which I dont think it's supposed to.
Say I am doing some sort of database connection/initialization in that endpoint (which I am not supposed to but say I am doing it anyway), Vercel executing that function during build is going to cause some unexpected side effect and if someone is not aware of this behaviour is gonna have a hard time figure out what's happening.
Is this a an expected behaviour and supposed to be this way?
import { NextResponse } from "next/server";
export async function GET(request: Request) { console.trace('Fetching products...') return NextResponse.json({});
}