Commit 7adeb8e
committed
fix: prevent duplicate Location and x-nextjs-stale-time headers on redirect
When a page redirect is rendered, the render phase sets Location via
setHeader on the response. Then the cache serving code in app-page.ts
re-applies cached headers using the native appendHeader, which appends
unconditionally without checking for existing values. This produces
duplicate Location headers (e.g. Location: /redirect, Location: /redirect).
Behind Cloudflare or similar proxies, duplicated Location headers get
merged into "Location: /redirect, /redirect" which is an invalid
redirect target, breaking navigation entirely.
Use setHeader (replace) instead of appendHeader (add) for headers that
don't support multiple values. Keep appendHeader for set-cookie, vary,
www-authenticate, and proxy-authenticate which are multi-value by spec.
Fixes #821171 parent dfbf3c4 commit 7adeb8e
1 file changed
+23
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1608 | 1608 | | |
1609 | 1609 | | |
1610 | 1610 | | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
1611 | 1621 | | |
1612 | 1622 | | |
1613 | 1623 | | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
1614 | 1627 | | |
1615 | 1628 | | |
1616 | 1629 | | |
1617 | 1630 | | |
1618 | 1631 | | |
1619 | 1632 | | |
1620 | | - | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
1621 | 1638 | | |
1622 | | - | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
1623 | 1644 | | |
1624 | 1645 | | |
1625 | 1646 | | |
| |||
0 commit comments