payloadcms / payload

The best way to build a modern backend + admin UI. No black magic, all TypeScript, and fully open-source, Payload is both an app framework and a headless CMS.
https://payloadcms.com
MIT License
20.99k stars 1.26k forks source link

feat: add the ability to pass in a response to upload handlers #6926

Closed JarrodMFlesch closed 2 days ago

JarrodMFlesch commented 3 days ago

Description

Adds the ability to set response headers by using a new uploads.modifyResponseHeaders property. You could previously do this in Express in Payload v2.

You can do this like so:

upload: {
  modifyResponseHeaders: ({ headers }) => {
    headers.set('Cache-Control', 'public, max-age=86400')
    return headers
  }
},

Type of change

Checklist: