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

Next.Js Dev Serves _ClientMiddlewareManifest.Js With Application/Json MIME, Breaking Script Execution When Nosniff Is Enabled

When X-Content-Type-Options: nosniff is set, Chrome refuses to execute the dev-only _clientMiddlewareManifest.js script because Next.js serves it with Content-Type application/json instead of text/javascript. This breaks client middleware in development.

highConfidence 90%Next.jsnext buildApp RouterHydrationAffected V16.2.0Affected V16.2.1-Canary.16

Origin Analysis

Next.js dev server returns the client middleware manifest as JSON data with Content-Type application/json because it is serialized JSON. However the file is loaded via a <script> tag, and browsers with strict MIME type checking (triggered by nosniff) require JavaScript MIME for execution. The mismatch between the .js extension/script usage and the JSON content type is the root defect.
1. Create a Next.js 16.2.x app. 2. In next.config.js add headers: async headers() { return [{ source: '/:path*', headers: [{ key: 'X-Content-Type-Options', value: 'nosniff' }] }] } 3. Run next dev. 4. Open the app in Chrome and view the console. 5. Observe the error: Refused to execute script from 'http://localhost:3000/_next/static/development/_clientMiddlewareManifest.js' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.

Fixing Code Block

Edge Case Audit

Changing the Content-Type may break any dev-only tooling or fetch calls that expect application/json for this endpoint. The fix should be scoped to the dev server response for _clientMiddlewareManifest.js only, and not applied to other manifest endpoints that are fetched as JSON. Rollback: revert the header change and instead exclude /_next/static/ from the nosniff header in development. Test with nosniff enabled and disabled, and across Chrome, Firefox, and Safari. Be aware that CDNs or custom dev servers might override Content-Type, requiring additional configuration.

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