This PR adds `cacheTags: boolean` (default `true`) to allow users to disable the appended document updatedAt value in the case of hosting with third party CDNs which may not allow additional search params and throw an error. It also fixes how we append this value to consider the case where the URL already contains parameters and appends it with `&` instead. In the future `cacheTags` can be made an object to allow granularity for disabling `eTag` headers used for caching as well. The cache tag control should help with these two issues: - Fixes https://github.com/payloadcms/payload/issues/9880 - Fixes https://github.com/payloadcms/payload/issues/9993 The appending of the value correctly addresses this: - Fixes https://github.com/payloadcms/payload/issues/10139
28 lines
719 B
TypeScript
28 lines
719 B
TypeScript
import type { CollectionConfig } from 'payload'
|
|
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
import { adminThumbnailWithSearchQueries } from '../../shared.js'
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export const AdminThumbnailWithSearchQueries: CollectionConfig = {
|
|
slug: adminThumbnailWithSearchQueries,
|
|
hooks: {
|
|
afterRead: [
|
|
({ doc }) => {
|
|
return {
|
|
...doc,
|
|
// Test that URLs with additional queries are handled correctly
|
|
thumbnailURL: `/_next/image?url=${doc.url}&w=384&q=5`,
|
|
}
|
|
},
|
|
],
|
|
},
|
|
upload: {
|
|
staticDir: path.resolve(dirname, 'test/uploads/media'),
|
|
},
|
|
fields: [],
|
|
}
|