From 9bedc91ee05026be078894cfeeb7b54b151a8eed Mon Sep 17 00:00:00 2001 From: Pringgo Radianto Date: Mon, 7 Oct 2024 20:02:10 +0700 Subject: [PATCH] fix: fix promise handler and proxyOptions --- src/runtime/server/plugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/server/plugin.ts b/src/runtime/server/plugin.ts index 6cfef45..6430d00 100644 --- a/src/runtime/server/plugin.ts +++ b/src/runtime/server/plugin.ts @@ -17,7 +17,7 @@ const proxyHandler = (config: ProxyParty) => { const url = joinURL(config.target, path) if (typeof config.handler === 'function') { - if (config.handler instanceof Promise) { + if (config.handler.constructor.name == 'AsyncFunction') { await config.handler(event) } else { @@ -30,7 +30,7 @@ const proxyHandler = (config: ProxyParty) => { } const options = typeof config.proxyOptions === 'function' - ? config.proxyOptions instanceof Promise + ? config.proxyOptions.constructor.name == 'AsyncFunction' ? await config.proxyOptions(event) : config.proxyOptions(event) : config.proxyOptions