fix: bind window.fetch at boot so lnurlcash-kit transport works in browsers

This commit is contained in:
2026-08-19 21:36:48 +02:00
parent 1fe1453745
commit 1839700215
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -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);
});