Skip to content

Commit 4a8d3a0

Browse files
fix: ensures req has headers, passes it through in view rendering (#7012)
`req.headers` was missing when admin views fetched data to render. This threads headers through inside of initPage.
1 parent ca5f330 commit 4a8d3a0

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

packages/next/src/utilities/initPage/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const initPage = async ({
5959
{
6060
fallbackLocale: null,
6161
req: {
62+
headers,
6263
host: headers.get('host'),
6364
i18n,
6465
query: qs.parse(queryString, {

packages/next/src/views/List/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const ListView: React.FC<AdminViewProps> = async ({
2727
collectionConfig,
2828
locale: fullLocale,
2929
permissions,
30+
req,
3031
req: {
3132
i18n,
3233
locale,
@@ -53,6 +54,7 @@ export const ListView: React.FC<AdminViewProps> = async ({
5354
collection: 'payload-preferences',
5455
depth: 0,
5556
limit: 1,
57+
req,
5658
user,
5759
where: {
5860
key: {
@@ -109,6 +111,7 @@ export const ListView: React.FC<AdminViewProps> = async ({
109111
locale,
110112
overrideAccess: false,
111113
page,
114+
req,
112115
sort,
113116
user,
114117
where: whereQuery || {},

packages/next/src/views/Version/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const VersionView: EditViewComponent = async (props) => {
1919
docID: id,
2020
globalConfig,
2121
permissions,
22+
req,
2223
req: { payload, payload: { config } = {}, user } = {},
2324
} = initPageResult
2425

@@ -48,6 +49,7 @@ export const VersionView: EditViewComponent = async (props) => {
4849
depth: 1,
4950
locale: '*',
5051
overrideAccess: false,
52+
req,
5153
user,
5254
})
5355

@@ -58,6 +60,7 @@ export const VersionView: EditViewComponent = async (props) => {
5860
draft: false,
5961
locale: '*',
6062
overrideAccess: false,
63+
req,
6164
user,
6265
})
6366

@@ -68,6 +71,7 @@ export const VersionView: EditViewComponent = async (props) => {
6871
draft: true,
6972
locale: '*',
7073
overrideAccess: false,
74+
req,
7175
user,
7276
})
7377
} catch (error) {
@@ -87,6 +91,7 @@ export const VersionView: EditViewComponent = async (props) => {
8791
depth: 1,
8892
locale: '*',
8993
overrideAccess: false,
94+
req,
9095
user,
9196
})
9297

@@ -96,6 +101,7 @@ export const VersionView: EditViewComponent = async (props) => {
96101
draft: false,
97102
locale: '*',
98103
overrideAccess: false,
104+
req,
99105
user,
100106
})
101107

@@ -105,6 +111,7 @@ export const VersionView: EditViewComponent = async (props) => {
105111
draft: true,
106112
locale: '*',
107113
overrideAccess: false,
114+
req,
108115
user,
109116
})
110117
} catch (error) {

packages/next/src/views/Versions/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const VersionsView: EditViewComponent = async (props) => {
1919
collectionConfig,
2020
docID: id,
2121
globalConfig,
22+
req,
2223
req: {
2324
i18n,
2425
payload,
@@ -48,6 +49,7 @@ export const VersionsView: EditViewComponent = async (props) => {
4849
limit: limitToUse,
4950
overrideAccess: false,
5051
page: page ? parseInt(page.toString(), 10) : undefined,
52+
req,
5153
sort: sort as string,
5254
user,
5355
where: {
@@ -70,6 +72,7 @@ export const VersionsView: EditViewComponent = async (props) => {
7072
limit: limitToUse,
7173
overrideAccess: false,
7274
page: page ? parseInt(page as string, 10) : undefined,
75+
req,
7376
sort: sort as string,
7477
user,
7578
})

0 commit comments

Comments
 (0)