---
title: "Solving Next.js 404 for \"on-demand-entries-client\""
description: Solving a weird Next.js 404 issue on-demand-client-entries.js - turns out it was the middleware.
image: https://blog.appstruct.io/hubfs/Screenshot%202023-05-18%20at%2011.23.09.png
---

[![Appstruct logo](https://blog.appstruct.io/hs-fs/hubfs/appstruct-ai-dark-final-2.png?width=1380&height=316&name=appstruct-ai-dark-final-2.png "Appstruct logo")](http://appstruct.io)

[![Learn More](https://no-cache.hubspot.com/cta/default/2512351/3b25e994-d5b3-4bc7-8161-d3c5788b48e9.png)](https://cta-redirect.hubspot.com/cta/redirect/2512351/3b25e994-d5b3-4bc7-8161-d3c5788b48e9)

# appstruct.io Blog

## [Solving Next.js 404 for "on-demand-entries-client"](https://blog.appstruct.io/blog/solving-next.js-404-for-on-demand-entries-client)

 [fa icon="calendar"] 18-May-2023 11:30:54 / by [Stephen McElhinney](https://blog.appstruct.io/blog/author/stephen-mcelhinney)

![Stephen McElhinney](https://blog.appstruct.io/hs-fs/hubfs/avatar.png?width=35&name=avatar.png)

- [Tweet](https://twitter.com/share)

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](https://blog.appstruct.io/hs-fs/hubfs/Screenshot%202023-05-18%20at%2011.23.09.png?width=3322&height=2526&name=Screenshot%202023-05-18%20at%2011.23.09.png)

 

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](https://blog.appstruct.io/blog/topic/typescript), [nextjs](https://blog.appstruct.io/blog/topic/nextjs)

![Stephen McElhinney](https://blog.appstruct.io/hs-fs/hubfs/avatar.png?width=100&height=100&name=avatar.png)

#### Written by [Stephen McElhinney](https://blog.appstruct.io/blog/author/stephen-mcelhinney)

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

[[fa icon="twitter-square"]Twitter](https://twitter.com/tboxdotio)

### Subscribe to Email Updates

- Recent
- Popular
- Categories

### Lists by Topic

- [nextjs (1)](https://blog.appstruct.io/blog/topic/nextjs)
- [typescript (1)](https://blog.appstruct.io/blog/topic/typescript)

### Posts by Topic

- [nextjs (1)](https://blog.appstruct.io/blog/topic/nextjs)
- [typescript (1)](https://blog.appstruct.io/blog/topic/typescript)

### Recent Posts