Edge Function Logs display nothing

When trying to view middleware logs in our current deployment (forgive me for not providing the URL here in a public post), nothing appears in the log, aside from the loading spinner (/). What are the requirements or constraints around viewing middleware logs?

Hi @Lumos_Labs, if possible can you share a code snippet of your function for me to help with the debugging?


This page: Function logs | Netlify Docs implies that something should be logged on every invocation of the middleware.

Our function basically:

export function middleware(request: NextRequest) {
  const { pathname, origin } = request.nextUrl

  if (pathname === '/somePath') {
    const response = NextResponse.redirect(new URL('/', origin))
    response.cookies.set('someCookie', 'value')
    return response
  return NextResponse.next()

We’re trying to debug an issue in which the NextRequest in our middleware no longer contains our public URL (as origin, pathname, host, or referer), but rather our netlify URL, to which traffic from our public URL is distributed via Cloudfront. NextJS v12 + @netlify/plugin-nextjs v4.0.0 worked as expected, with the NextRequest containing our public URL, allowing us to redirect back to our public URL. NextJS v13.0.3 + @netlify/plugin-nextjs v4.29.1 works differently, and the difference we’ve noticed in the build pipeline on Netlify is that with the older versions, we are told Skipped moving 42 files because they match middleware, so cannot be deployed to the CDN and will be served from the origin instead, and with the newer versions we are told Moved 42 files... Deploying middleware and functions to Netlify Edge functions.

But the intent here is just to see log output, and on none of our deploys are we seeing anything at all, other than the spinner.

Hi @Lumos_Labs, thanks for sharing the code snippet.

I can’t tell for sure what might be causing the issue with the function logs.

However just want to find out if the problem persists if you are on Next.js 12.


We would need the site name to check further @Lumos_Labs.

1 Like