From 18397002150eca483ba1f00951715e30fbacd792 Mon Sep 17 00:00:00 2001 From: protom Date: Wed, 19 Aug 2026 21:36:48 +0200 Subject: [PATCH] fix: bind window.fetch at boot so lnurlcash-kit transport works in browsers --- quasar.config.ts | 2 +- src/boot/kit-fetch.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/boot/kit-fetch.ts diff --git a/quasar.config.ts b/quasar.config.ts index cdc843c..306fb85 100644 --- a/quasar.config.ts +++ b/quasar.config.ts @@ -11,7 +11,7 @@ export default defineConfig((ctx) => { // app boot file (/src/boot) // --> boot files are part of "main.js" // https://v2.quasar.dev/quasar-cli-vite/boot-files - boot: ['i18n', 'wallet'], + boot: ['i18n', 'kit-fetch', 'wallet'], // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#css css: ['app.scss'], diff --git a/src/boot/kit-fetch.ts b/src/boot/kit-fetch.ts new file mode 100644 index 0000000..04c40f7 --- /dev/null +++ b/src/boot/kit-fetch.ts @@ -0,0 +1,14 @@ +import { defineBoot } from '#q-app'; + +// lnurlcash-kit's transport resolves its fetch as `options.fetch ?? +// globalThis.fetch` and then invokes it as a method on the options object. +// In a browser, calling window.fetch with any receiver other than window +// throws a synchronous "Illegal invocation" TypeError - before any request +// is even attempted (Node's fetch has no such receiver check, so the unit +// tests never see it; every kit network call failed in real browsers). +// Binding the global once here means the kit's captured default is already +// bound, whichever receiver it is invoked with. Remove once lnurlcash-kit +// fixes this upstream in its transport (resolveOptions). +export default defineBoot(() => { + window.fetch = window.fetch.bind(window); +});