CSP FOR ISR PAGES? #95396
Replies: 1 comment
-
|
Hi, @lleo880055-afk This is a request for better CSP handling across mixed rendering modes (ISR + dynamic pages) in Next.js, specifically around how headers are inherited or reused when navigating between routes like ISR-generated pages and fully dynamic routes (cart/checkout). Current behavior (what is happening)In Next.js today, CSP headers are applied per-route based on the response type:
The issue arises when navigation or routing reuse causes a mismatch in expectations:
This is especially noticeable in ecommerce flows where:
Root problem area (architectural)This is not strictly an ISR bug—it is a header propagation and caching boundary problem:
Expected behavior (what users want)For production ecommerce/security-sensitive apps:
Possible design directions (for Next.js team)1. Explicit CSP scoping per route segmentAllow CSP to be defined at:
with strict override precedence for dynamic routes like:
2. Separate header caching strategy for ISREnsure ISR cached responses:
3. Clear precedence rulesDefine explicit hierarchy: 4. Middleware isolation mode (potential feature)A way to opt into:
Workaround todayUntil framework-level support improves, typical mitigation is:
Example pattern:
ConclusionThis is fundamentally a header scoping + caching boundary issue in mixed ISR/dynamic applications. It becomes more visible in App Router architectures where layouts, middleware, and ISR caching all contribute to overlapping header lifetimes. A more explicit per-route CSP model with clear override precedence would resolve this class of issues cleanly for ecommerce and other security-sensitive applications. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
When do we get csp for isr pages? lash csp homepage entry leads to lash csp on cart and checkout pages which are not isr pages and have proper csp.
Non-Goals
Background
Needed for Webshops and Checkout workflows when the project has somewhere isr pages.
Proposal
Dont know too much sorry.
Beta Was this translation helpful? Give feedback.
All reactions