Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to override Supabase service URLs in client #443

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/SupabaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ export default class SupabaseClient {
const _supabaseUrl = stripTrailingSlash(supabaseUrl)
const settings = { ...DEFAULT_OPTIONS, ...options }

this.restUrl = `${_supabaseUrl}/rest/v1`
this.realtimeUrl = `${_supabaseUrl}/realtime/v1`.replace('http', 'ws')
this.authUrl = `${_supabaseUrl}/auth/v1`
this.storageUrl = `${_supabaseUrl}/storage/v1`
this.restUrl = options?.restUrl || `${_supabaseUrl}/rest/v1`
this.realtimeUrl = options?.realtimeUrl || `${_supabaseUrl}/realtime/v1`.replace('http', 'ws')
this.authUrl = options?.authUrl || `${_supabaseUrl}/auth/v1`
this.storageUrl = options?.storageUrl || `${_supabaseUrl}/storage/v1`

const isPlatform = _supabaseUrl.match(/(supabase\.co)|(supabase\.in)/)
if (isPlatform) {
Expand Down
20 changes: 20 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ export type SupabaseClientOptions = {
* Options passed to the gotrue-js instance
*/
cookieOptions?: SupabaseAuthClientOptions['cookieOptions']

/**
* Override the restUrl
*/
restUrl?: string

/**
* Override the realtimeUrl (must be ws:// scheme)
*/
realtimeUrl?: string

/**
* Override the authUrl
*/
authUrl?: string

/**
* Override the storageUrl
*/
storageUrl?: string
}

export type SupabaseRealtimePayload<T> = {
Expand Down