The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: prevent document unload if gotrue is debugged and in a fetch
Stojan Dimitrovski5a98d79715ff
diff --git a/packages/common/gotrue.ts b/packages/common/gotrue.tsindex 2ef1061dfe7..65f86f9e9e6 100644--- a/packages/common/gotrue.ts+++ b/packages/common/gotrue.ts@@ -10,9 +10,33 @@ const debug =globalThis.localStorage &&globalThis.localStorage.getItem(AUTH_DEBUG_KEY) === 'true'+let customFetch = globalThis.fetch++if (debug) {+ customFetch = async (a, b) => {+ const el = (event: any) => {+ event.preventDefault()+ console.log('GoTrue fetch in progress detected in beforeunload!', a, b)+ }++ try {+ if (document) {+ document.addEventListener('beforeunload', el, { capture: true })+ }++ return await globalThis.fetch(a, b)+ } finally {+ if (document) {+ document.removeEventListener('beforeunload', el, { capture: true })+ }+ }+ }+}+export const gotrueClient = new GoTrueClient({url: process.env.NEXT_PUBLIC_GOTRUE_URL,storageKey: STORAGE_KEY,detectSessionInUrl: true,debug,+ fetch: customFetch,})