Skip to content

Next.js 16: rewrite/proxy no longer works in production (500), but works in dev #87071

@TheDanniCraft

Description

@TheDanniCraft

Link to the code that reproduces this issue

https://github.com/TheDanniCraft/clipify

To Reproduce

  1. Start the server in dev mode
  2. the URL /js/script.file-downloads.hash.outbound-links.tagged-events.js is correctly proxied to https://analytics.thedannicraft.de//js/script.file-downloads.hash.outbound-links.tagged-events.js
  3. Build (next build --webpack)
  4. Start (next start)
  5. On prod build /js/script.file-downloads.hash.outbound-links.tagged-events.js returns HTTP 500 Internal Server Error

Current vs. Expected behavior

Expected behavior (worked in next v15 before upgrading to next v16)

The rewrite should behave the same way in production as in development and proxy the file to:
https://analytics.thedannicraft.de//js/script.file-downloads.hash.outbound-links.tagged-events.js

Actual behavior:

Dev mode: Works as expected
Production build: Returns 500

I also verified the rewrite exists at build time by logging (when next config is parsed):

const rewrites = await config.rewrites();
console.log(rewrites.find(r => r.source === "/js/script.file-downloads.hash.outbound-links.tagged-events.js"));

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
  Available memory (MB): 8035
  Available CPU cores: 8
Binaries:
  Node: 22.14.0
  npm: 11.4.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.8
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: standalone

Which area(s) are affected? (Select all that apply)

Webpack, Output, Pages Router

Which stage(s) are affected? (Select all that apply)

next build (local), next start (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    OutputRelated to the the output configuration option.Pages RouterRelated to Pages Router.WebpackRelated to Webpack with Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions