mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
We noticed that our internal soft tags were unexpectedly including the query string for SSR routes which causes the URL soft tag to not match correctly so this ensures we properly normalize the value to just the pathname and not include the query.
25 lines
539 B
JavaScript
25 lines
539 B
JavaScript
const cache = new Map()
|
|
|
|
module.exports = class CacheHandler {
|
|
constructor() {
|
|
console.log('initialized custom cache-handler')
|
|
}
|
|
|
|
async get(key, ctx) {
|
|
console.log('cache-handler get', key, ctx)
|
|
|
|
if (ctx.softTags?.some((tag) => tag.includes('?'))) {
|
|
throw new Error(`invalid soft tag found should only be pathname`)
|
|
}
|
|
return cache.get(key)
|
|
}
|
|
|
|
async set(key, data, ctx) {
|
|
console.log('cache-handler set', key, ctx)
|
|
cache.set(key, {
|
|
value: data,
|
|
lastModified: Date.now(),
|
|
})
|
|
}
|
|
}
|