AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Adding Proxy Causes Requests To _Next/Data Which Return Empty Data

When a proxy (or middleware) file is present in a Pages Router application, Next.js prefetches _next/data JSON for all linked pages, even those without data fetching methods. These requests return an empty object {} instead of the expected {"pageProps":{}}, leading to unnecessary network traffic and potential client-side errors after application rebuilds.

highConfidence 75%Next.jsApp RouterRoute HandlersAffected V16.1.6

Origin Analysis

The default value of experimental.middlewarePrefetch is 'flexible'. When middleware or proxy is present, this setting causes Next.js to prefetch data for all pages via _next/data, including static pages that do not export getStaticProps or getServerSideProps. The data endpoint then returns an empty object because there is no page data to serialize.
1. Create a Pages Router application with a proxy.ts file (or middleware.ts). 2. Add one or more <Link> components to a page. 3. Build and start the application (npm run build && npm start). 4. Open the browser DevTools Network tab and navigate to the starting page. 5. Observe additional _next/data/*.json requests for each linked page. 6. Inspect the response of any _next/data request; it is an empty JSON object {}.

Fixing Code Block

Edge Case Audit

This configuration is experimental and may be removed or change behavior in future Next.js versions. It may reduce prefetching for pages that rely on middleware-injected data, so test navigation performance after applying. To rollback, remove the experimental block and rebuild. Ensure your proxy/middleware matcher is correctly defined to avoid missing needed prefetch for dynamic pages. This is a workaround, not an official fix.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state