Skip to content

Commit 1658209

Browse files
committed
fix: revive server-only pageContext types such as pageContext.headers (fix #3087)
1 parent a8edfbd commit 1658209

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

packages/vike/src/server/runtime/renderPageServer/createPageContextServer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import {
1919

2020
type PageContextCreatedServer = Awaited<ReturnType<typeof createPageContextServer>>
2121
function createPageContextServer(
22-
pageContextInit: PageContextInit,
22+
pageContextInit: PageContextInit & {
23+
// TO-DO/next-major-release: remove
24+
headers?: Record<string, unknown>
25+
},
2326
globalContext: GlobalContextServerInternal,
2427
args: {
2528
requestId: number

packages/vike/src/types/PageContext.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ type PageContextInit = {
179179
headersOriginal?: unknown // We set it to the type `unknown` instead of the type `HeadersInit` because `HeadersInit` isn't accurate: for example, `http.IncomingHttpHeaders` is a valid input for `new Headers()` but doesn't match the `HeadersInit` init.
180180
/** @deprecated Set `pageContextInit.urlOriginal` instead */ // TO-DO/next-major-release: remove
181181
url?: string
182-
/** @deprecated Set pageContextInit.headersOriginal instead */ // TO-DO/next-major-release: remove
183-
headers?: Record<string, string>
184182
}
185183

186184
type PageContextBuiltInServer<Data> = PageContextBuiltInCommon<Data> &
@@ -349,6 +347,9 @@ type PageContextClientCommon = {
349347
* https://vike.dev/pageContext#isPrerendering
350348
*/
351349
isPrerendering: false
350+
351+
cspNonce?: undefined
352+
headers?: undefined
352353
}
353354

354355
type PageContextInternalServer = Omit<

0 commit comments

Comments
 (0)