Why is my site invoking hundreds of Next.js Server Handler functions even with low usage?

Found a way to get information about the 404s without having to use Netlify Analytics.

Basically I am logging the current path on my 404 page. I also added the revalidate: 30 on the getStaticProps to have it log once every 30 seconds (assuming there are 404 requests all the time).

import { getClient } from 'lib/sanity.server';
import { useRouter } from 'next/router';

import Layout from 'components/Layout';
import page404groq from 'groq/page404.groq';
import Page404Template from 'templates/Page404';

export default function Page404({ data, preview }) {
  const router = useRouter();
  const currentPath = router.asPath;
  console.log('404 url path', currentPath);

  return (
    <Layout data={data} preview={preview}>
      <Page404Template />
    </Layout>
  )
}

export async function getStaticProps({ preview = false }) {
  const data = await getClient(preview).fetch(page404groq)

  return {
    revalidate: 30,
    props: {
      data,
      preview,
    },
  }
}

With this I found the request were for wordpress files that didn’t end with .php (which is why my filter was not catching them), so I updated my edge function as below, and am now waiting to see if it works, but I see no reason not to.

import type { Config } from '@netlify/edge-functions'

export default async function () {
  const html404 =
    '<!DOCTYPE html><html><head><title>404 Not Found</title></head><body><h1>404 Not Found</h1></body></html>'

  return new Response(html404, {
    status: 404,
    headers: {
      'Content-Type': 'text/html',
      'netlify-cdn-cache-control':
        'durable, immutable, max-age=31536000, public',
    },
  })
}

export const config: Config = {
  cache: 'manual',
  pattern:
    '^.*((wp-admin|wp-content|wp-includes|\\.htaccess).*|\\.[Pp][Hh][Pp])$',
}