Skip to content

Commit

Permalink
Merge pull request supabase#64 from supabase/fix/missing_redirects
Browse files Browse the repository at this point in the history
fix: supabase#66. Missing redirects on some routes
  • Loading branch information
kiwicopple committed Feb 23, 2021
2 parents a6af15d + ad8131d commit d993b54
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/GoTrueApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ export default class GoTrueApi {
} = {}
): Promise<{ data: Session | null; error: Error | null }> {
try {
let headers = { ...this.headers }
if (options.redirectTo) {
headers['referer'] = options.redirectTo
}
const data = await post(
`${this.url}/token?grant_type=password`,
{ email, password },
{ headers: this.headers }
{ headers }
)
return { data, error: null }
} catch (error) {
Expand All @@ -91,7 +95,11 @@ export default class GoTrueApi {
} = {}
): Promise<{ data: {} | null; error: Error | null }> {
try {
const data = await post(`${this.url}/magiclink`, { email }, { headers: this.headers })
let headers = { ...this.headers }
if (options.redirectTo) {
headers['referer'] = options.redirectTo
}
const data = await post(`${this.url}/magiclink`, { email }, { headers })
return { data, error: null }
} catch (error) {
return { data: null, error }
Expand All @@ -110,7 +118,11 @@ export default class GoTrueApi {
} = {}
): Promise<{ data: {} | null; error: Error | null }> {
try {
const data = await post(`${this.url}/invite`, { email }, { headers: this.headers })
let headers = { ...this.headers }
if (options.redirectTo) {
headers['referer'] = options.redirectTo
}
const data = await post(`${this.url}/invite`, { email }, { headers })
return { data, error: null }
} catch (error) {
return { data: null, error }
Expand All @@ -129,7 +141,11 @@ export default class GoTrueApi {
} = {}
): Promise<{ data: {} | null; error: Error | null }> {
try {
const data = await post(`${this.url}/recover`, { email }, { headers: this.headers })
let headers = { ...this.headers }
if (options.redirectTo) {
headers['referer'] = options.redirectTo
}
const data = await post(`${this.url}/recover`, { email }, { headers })
return { data, error: null }
} catch (error) {
return { data: null, error }
Expand Down

0 comments on commit d993b54

Please sign in to comment.