Skip to content

Ability to set custom headers

Compare
Choose a tag to compare
@neg4n neg4n released this 26 Jul 05:01
· 9 commits to main since this release
fe8dbdf

Added return value to hook function passed in configuration object. From now on, this function can return Map containing custom headers that will be set before sending response with open-graph image to client.

Example code:

import { withOGImage } from 'next-api-og-image'

export default withOGImage({
  template: {
    react: ({ myQueryParam }) => <div>🔥 {myQueryParam}</div>,
  },
  hook: () => {
    const headers = new Map()
    headers.set('X-My-Header', 'cool-thing')
    return headers
  },
})

Full Changelog: 4.1.0...4.2.0