mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
When a page is accessed via a rewrite, use the destination path (not the source path) when computing implicit tags. This ensures that calling `revalidatePath('/dest')` correctly invalidates cache entries for pages rewritten to that destination.
Fixes `'use cache'` and fetch cache with rewrites. ISR page cache was not affected because it already uses the rewritten pathname as the cache key (via `resolvedUrlPathname` in `base-server.ts`).
25 lines
528 B
JavaScript
25 lines
528 B
JavaScript
/**
|
|
* @type {import('next').NextConfig}
|
|
*/
|
|
module.exports = {
|
|
rewrites: async () => {
|
|
const isCacheComponentsEnabled =
|
|
process.env.__NEXT_CACHE_COMPONENTS === 'true'
|
|
|
|
return [
|
|
{
|
|
source: '/static',
|
|
destination: isCacheComponentsEnabled
|
|
? '/cache-components/static'
|
|
: '/legacy/static',
|
|
},
|
|
{
|
|
source: '/dynamic',
|
|
destination: isCacheComponentsEnabled
|
|
? '/cache-components/dynamic'
|
|
: '/legacy/dynamic',
|
|
},
|
|
]
|
|
},
|
|
}
|