Learn More

appstruct.io Blog

Solving Next.js 404 for "on-demand-entries-client"

[fa icon="calendar"] 18-May-2023 11:30:54 / by Stephen McElhinney

Stephen McElhinney

I thought I'd write a quick solve here, because it took me a while to figure this out. I was tinkering around with my Next.js project, which was working fine, when suddenly this started happening..

Screenshot 2023-05-18 at 11.23.09

 

Cue about 1.5 hours of root cause analysis, and trying to Google "on-demand-entries-client" and "Next.js 404" on Google, and no article was helping me. But then, a brain wave.. what's my middleware doing?

So I checked my middleware, and sure enough, this block was there.. 

  if (!process.env.EDGE_CONFIG || !process.env.VERCEL_ENV) {
    req.nextUrl.pathname = `/missing-edge-config`;
    return NextResponse.rewrite(req.nextUrl);
  }

This was the culprit. I had indeed forgotten to replace one of these variables in my local env. And that missing-edge-config page doesn't actually exist in my codebase! (It was a copy/paste from a Vercel blog post)

So, yeah - check your middleware for funkiness. Hope that saved you some time. 

 

Topics: typescript, nextjs

Stephen McElhinney

Written by Stephen McElhinney

Former freelancer / contractor, providing professional services to contractors in the IT and Technology sector.

Subscribe to Email Updates

Posts by Topic

Recent Posts