Skip to content

Commit ddc9d97

Browse files
authored
feat: adds x-powered-by Payload header in next config (#9027)
Adds the `x-powered-by` header to include Payload alongside Next.js End result looks like this ``` x-powered-by: Next.js, Payload ``` It also respects the nextConfig `poweredBy: false` to completely disable it
1 parent 3e31b7a commit ddc9d97

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/next/src/withPayload.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export const withPayload = (nextConfig = {}) => {
1313
env.NEXT_PUBLIC_ENABLE_ROUTER_CACHE_REFRESH = 'true'
1414
}
1515

16+
const poweredByHeader = {
17+
key: 'X-Powered-By',
18+
value: 'Next.js, Payload',
19+
}
20+
1621
/**
1722
* @type {import('next').NextConfig}
1823
*/
@@ -41,6 +46,8 @@ export const withPayload = (nextConfig = {}) => {
4146
},
4247
},
4348
},
49+
// We disable the poweredByHeader here because we add it manually in the headers function below
50+
...(nextConfig?.poweredByHeader !== false ? { poweredByHeader: false } : {}),
4451
headers: async () => {
4552
const headersFromConfig = 'headers' in nextConfig ? await nextConfig.headers() : []
4653

@@ -61,6 +68,7 @@ export const withPayload = (nextConfig = {}) => {
6168
key: 'Critical-CH',
6269
value: 'Sec-CH-Prefers-Color-Scheme',
6370
},
71+
...(nextConfig?.poweredByHeader !== false ? [poweredByHeader] : []),
6472
],
6573
},
6674
]

0 commit comments

Comments
 (0)