I saw your other post about the ref being invalid, we'll reply over there. It's better to keep separate threads for separate topics, in case other people need help 
Hey, thanks a lot for your input. Just for clarification - what do you mean with this:
** Add console.log
inside /api/v2
to track what triggers it.*
** Log request headers and referrer info.*
If you have a custom API route at /api/v2
, add logging inside it to see when and why it's getting hit.
Example:
export default async function handler(req, res) {
console.log("API /api/v2 hit at:", new Date().toISOString());
console.log("Request headers:", req.headers);
console.log("Request body:", req.body);
return res.status(200).json({ message: "OK" });
}
This will help you track:
- When
/api/v2
gets hit.
- How often it's called.
- What headers and body are sent (which can reveal the source of calls).
If you don’t have a custom API route at /api/v2
, but it’s a Prismic API URL, check where it’s being fetched in your Next.js code.
If you log request headers and referrer info, it will help you identify who or what is making the requests.
Inside /api/v2
(if it exists), add:
console.log("Referrer:", req.headers.referer || "No referrer");
console.log("User-Agent:", req.headers["user-agent"]);
- Referrer tells you where the request originated from.
- User-Agent helps identify if a bot or external service is calling it.
For example:
- If the referrer is an external site → someone else might be hitting your API.
- If it’s from your Next.js app → check your code for excessive calls.
You might already have this information in the CVS you got from the team!
Can the cache clearance have an impact this heavy?
Yes, but not directly in the way you're seeing.
Your package.json
build script:
"build": "rm -rf .next/cache/fetch-cache && next build"
- Deletes the fetch cache before every build.
- Forces Next.js to re-fetch all external data when the app starts.
If your app is auto-deploying frequently (e.g., every commit to Vercel or CI/CD runs), this could cause a high number of API calls whenever the app rebuilds and boots up.
How to Check if This Is the Cause
- Do you see API call spikes after every deployment?
- Does
/api/v2
get called immediately after a build finishes?
Hope that helps!