diff --git a/packages/router-core/package.json b/packages/router-core/package.json index a479f2dd04c..ee5783c2cb8 100644 --- a/packages/router-core/package.json +++ b/packages/router-core/package.json @@ -163,7 +163,7 @@ }, "dependencies": { "@tanstack/history": "workspace:*", - "cookie-es": "^2.0.0", + "cookie-es": "^3.0.0", "seroval": "^1.4.2", "seroval-plugins": "^1.4.2" }, diff --git a/packages/start-server-core/package.json b/packages/start-server-core/package.json index cd75951b750..1e1e9b951b2 100644 --- a/packages/start-server-core/package.json +++ b/packages/start-server-core/package.json @@ -82,13 +82,13 @@ "@tanstack/router-core": "workspace:*", "@tanstack/start-client-core": "workspace:*", "@tanstack/start-storage-context": "workspace:*", - "h3-v2": "npm:h3@2.0.1-rc.16", + "h3": "2.0.1-rc.19", "seroval": "^1.4.2" }, "devDependencies": { "@standard-schema/spec": "^1.0.0", "@tanstack/intent": "^0.0.14", - "cookie-es": "^2.0.0", + "cookie-es": "^3.0.0", "fetchdts": "^0.1.6", "vite": "*", "@types/node": ">=20" diff --git a/packages/start-server-core/src/request-response.ts b/packages/start-server-core/src/request-response.ts index f8de03aa566..780a76c4f6a 100644 --- a/packages/start-server-core/src/request-response.ts +++ b/packages/start-server-core/src/request-response.ts @@ -19,7 +19,7 @@ import { unsealSession as h3_unsealSession, updateSession as h3_updateSession, useSession as h3_useSession, -} from 'h3-v2' +} from 'h3' import type { RequestHeaderMap, RequestHeaderName, @@ -147,8 +147,7 @@ export function getRequest(): Request { } export function getRequestHeaders(): TypedHeaders { - // TODO `as any` not needed when fetchdts is updated - return getH3Event().req.headers as any + return getH3Event().req.headers } export function getRequestHeader(name: RequestHeaderName): string | undefined { @@ -284,7 +283,16 @@ export function setResponseStatus(code?: number, text?: string): void { */ export function getCookies(): Record { const event = getH3Event() - return h3_parseCookies(event) + const cookies = h3_parseCookies(event) + const normalizedCookies: Record = Object.create(null) + + for (const [name, value] of Object.entries(cookies)) { + if (value !== undefined) { + normalizedCookies[name] = value + } + } + + return normalizedCookies } /** @@ -296,7 +304,9 @@ export function getCookies(): Record { * ``` */ export function getCookie(name: string): string | undefined { - return getCookies()[name] || undefined + const event = getH3Event() + const cookies = h3_parseCookies(event) + return cookies[name] || undefined } /** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0e7aec511be..7b4ff6a9d50 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11983,8 +11983,8 @@ importers: specifier: workspace:* version: link:../history cookie-es: - specifier: ^2.0.0 - version: 2.0.0 + specifier: ^3.0.0 + version: 3.1.1 seroval: specifier: ^1.4.2 version: 1.4.2 @@ -12576,9 +12576,9 @@ importers: '@tanstack/start-storage-context': specifier: workspace:* version: link:../start-storage-context - h3-v2: - specifier: npm:h3@2.0.1-rc.16 - version: h3@2.0.1-rc.16(crossws@0.4.4(srvx@0.11.9)) + h3: + specifier: 2.0.1-rc.19 + version: 2.0.1-rc.19(crossws@0.4.4(srvx@0.11.13)) seroval: specifier: ^1.4.2 version: 1.4.2 @@ -12593,8 +12593,8 @@ importers: specifier: 25.0.9 version: 25.0.9 cookie-es: - specifier: ^2.0.0 - version: 2.0.0 + specifier: ^3.0.0 + version: 3.1.1 fetchdts: specifier: ^0.1.6 version: 0.1.7 @@ -19793,6 +19793,9 @@ packages: cookie-es@2.0.0: resolution: {integrity: sha512-RAj4E421UYRgqokKUmotqAwuplYw15qtdXfY+hGzgCJ/MBjCVZcSoHK/kH9kocfjRjcDME7IiDWR/1WX1TM2Pg==} + cookie-es@3.1.1: + resolution: {integrity: sha512-UaXxwISYJPTr9hwQxMFYZ7kNhSXboMXP+Z3TRX6f1/NyaGPfuNUZOWP1pUEb75B2HjfklIYLVRfWiFZJyC6Npg==} + cookie-signature@1.0.6: resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==} @@ -21163,6 +21166,16 @@ packages: crossws: optional: true + h3@2.0.1-rc.19: + resolution: {integrity: sha512-47er/mh8eGA7+0nvNUloalj+yTJ1ku8M0BVzA2I1ZHSlpfbUNdBK4LpWztfH7TwW6kuhF8MfAvl0AwB+X9B+2w==} + engines: {node: '>=20.11.1'} + hasBin: true + peerDependencies: + crossws: ^0.4.1 + peerDependenciesMeta: + crossws: + optional: true + handle-thing@2.0.1: resolution: {integrity: sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==} @@ -23989,6 +24002,11 @@ packages: engines: {node: '>=20.16.0'} hasBin: true + srvx@0.11.13: + resolution: {integrity: sha512-oknN6qduuMPafxKtHucUeG32Q963pjriA5g3/Bl05cwEsUe5VVbIU4qR9LrALHbipSCyBe+VmfDGGydqazDRkw==} + engines: {node: '>=20.16.0'} + hasBin: true + srvx@0.11.9: resolution: {integrity: sha512-97wWJS6F0KTKAhDlHVmBzMvlBOp5FiNp3XrLoodIgYJpXxgG5tE9rX4Pg7s46n2shI4wtEsMATTS1+rI3/ubzA==} engines: {node: '>=20.16.0'} @@ -33114,6 +33132,8 @@ snapshots: cookie-es@2.0.0: {} + cookie-es@3.1.1: {} + cookie-signature@1.0.6: {} cookie-signature@1.2.2: {} @@ -33184,6 +33204,11 @@ snapshots: optionalDependencies: srvx: 0.10.1 + crossws@0.4.4(srvx@0.11.13): + optionalDependencies: + srvx: 0.11.13 + optional: true + crossws@0.4.4(srvx@0.11.9): optionalDependencies: srvx: 0.11.9 @@ -34807,6 +34832,13 @@ snapshots: optionalDependencies: crossws: 0.4.4(srvx@0.11.9) + h3@2.0.1-rc.19(crossws@0.4.4(srvx@0.11.13)): + dependencies: + rou3: 0.8.1 + srvx: 0.11.13 + optionalDependencies: + crossws: 0.4.4(srvx@0.11.13) + handle-thing@2.0.1: {} has-async-hooks@1.0.0: {} @@ -37984,6 +38016,8 @@ snapshots: srvx@0.10.1: {} + srvx@0.11.13: {} + srvx@0.11.9: {} stable-hash-x@0.2.0: {}