Skip to content

Commit a94b7fb

Browse files
committed
fix(toEventHandler): validate h3 subapp instance to pick .handler
1 parent db7ef49 commit a94b7fb

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/h3.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import { toEventHandler } from "./handler.ts";
2929
export const NoHandler: EventHandler = () => kNotFound;
3030

3131
export class H3Core implements H3CoreType {
32+
static "~h3" = true;
33+
3234
readonly config: H3CoreConfig;
3335

3436
"~middleware": Middleware[];

src/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function toEventHandler(handler: HTTPHandler | undefined): EventHandler |
167167
if (typeof handler === "function") {
168168
return handler;
169169
}
170-
if (typeof (handler as H3Core)?.handler === "function") {
170+
if (typeof (handler as H3Core)?.handler === "function" && (handler as any).constructor?.["~h3"]) {
171171
return (handler as H3Core).handler;
172172
}
173173
if (typeof (handler as FetchableObject)?.fetch === "function") {

0 commit comments

Comments
 (0)