Skip to content

Commit

Permalink
fix: store fetchEvent in h3 context
Browse files Browse the repository at this point in the history
  • Loading branch information
katywings committed Jul 21, 2024
1 parent 23b01da commit cf5f476
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/start/src/server/fetchEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from "vinxi/http";
import type { FetchEvent, ResponseStub } from "./types";

const fetchEventSymbol = Symbol("fetchEvent");
const fetchEventContext = "solidFetchEvent";

export function createFetchEvent(event: H3Event): FetchEvent {
return {
Expand All @@ -32,12 +32,12 @@ export function cloneEvent<T extends FetchEvent>(fetchEvent: T): T {
}

export function getFetchEvent(h3Event: H3Event): FetchEvent {
if (!(h3Event as any)[fetchEventSymbol]) {
if (!h3Event.context[fetchEventContext]) {
const fetchEvent = createFetchEvent(h3Event);
(h3Event as any)[fetchEventSymbol] = fetchEvent;
h3Event.context[fetchEventContext] = fetchEvent;
}

return (h3Event as any)[fetchEventSymbol];
return h3Event.context[fetchEventContext];
}

export function mergeResponseHeaders(h3Event: H3Event, headers: Headers) {
Expand Down

0 comments on commit cf5f476

Please sign in to comment.