Skip to content

Commit

Permalink
Merge pull request #42 from supabase/chore/fix_bugs
Browse files Browse the repository at this point in the history
Fix bugs
  • Loading branch information
kiwicopple authored Jan 20, 2021
2 parents 57001d5 + 82ffec9 commit 34051e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import {
AuthChangeEvent,
CookieOptions,
} from './lib/types'
import { polyfillGlobalThis } from './lib/polyfills'

polyfillGlobalThis() // Make "globalThis" available

const DEFAULT_OPTIONS = {
url: GOTRUE_URL,
Expand Down
8 changes: 4 additions & 4 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const GOTRUE_URL = process?.env?.GOTRUE_URL || 'http://localhost:9999'
export const AUDIENCE = process?.env?.AUDIENCE || ''
export const GOTRUE_URL = 'http://localhost:9999'
export const AUDIENCE = ''
export const DEFAULT_HEADERS = {}
export const EXPIRY_MARGIN = process?.env?.EXPIRY_MARGIN || 60 * 1000
export const STORAGE_KEY = process?.env?.STORAGE_KEY || 'supabase.auth.token'
export const EXPIRY_MARGIN = 60 * 1000
export const STORAGE_KEY = 'supabase.auth.token'
export const COOKIE_OPTIONS = {
name: 'sb:token',
lifetime: 60 * 60 * 8,
Expand Down
16 changes: 16 additions & 0 deletions src/lib/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @ts-nocheck

/**
* https://mathiasbynens.be/notes/globalthis
*/
export function polyfillGlobalThis() {
if (typeof globalThis === 'object') return
Object.defineProperty(Object.prototype, '__magic__', {
get: function () {
return this
},
configurable: true,
})
__magic__.globalThis = __magic__
delete Object.prototype.__magic__
}

0 comments on commit 34051e7

Please sign in to comment.