@@ -36,7 +36,7 @@ public final class SupabaseClient: Sendable {
3636 $0. rest = PostgrestClient (
3737 url: databaseURL,
3838 schema: options. db. schema,
39- headers: defaultHeaders . dictionary ,
39+ headers: headers ,
4040 logger: options. global. logger,
4141 fetch: fetchWithAuth,
4242 encoder: options. db. encoder,
@@ -55,7 +55,7 @@ public final class SupabaseClient: Sendable {
5555 $0. storage = SupabaseStorageClient (
5656 configuration: StorageClientConfiguration (
5757 url: storageURL,
58- headers: defaultHeaders . dictionary ,
58+ headers: headers ,
5959 session: StorageHTTPSession ( fetch: fetchWithAuth, upload: uploadWithAuth) ,
6060 logger: options. global. logger
6161 )
@@ -77,7 +77,7 @@ public final class SupabaseClient: Sendable {
7777 if $0. functions == nil {
7878 $0. functions = FunctionsClient (
7979 url: functionsURL,
80- headers: defaultHeaders . dictionary ,
80+ headers: headers ,
8181 region: options. functions. region,
8282 logger: options. global. logger,
8383 fetch: fetchWithAuth
@@ -88,7 +88,13 @@ public final class SupabaseClient: Sendable {
8888 }
8989 }
9090
91- let defaultHeaders : HTTPHeaders
91+ let _headers : HTTPHeaders
92+ /// Headers provided to the inner clients on initialization.
93+ ///
94+ /// - Note: This collection is non-mutable, if you want to provide different headers, pass it in ``SupabaseClientOptions/GlobalOptions/headers``.
95+ public var headers : [ String : String ] {
96+ _headers. dictionary
97+ }
9298
9399 struct MutableState {
94100 var listenForAuthEventsTask : Task < Void , Never > ?
@@ -137,7 +143,7 @@ public final class SupabaseClient: Sendable {
137143 databaseURL = supabaseURL. appendingPathComponent ( " /rest/v1 " )
138144 functionsURL = supabaseURL. appendingPathComponent ( " /functions/v1 " )
139145
140- defaultHeaders = HTTPHeaders ( [
146+ _headers = HTTPHeaders ( [
141147 " X-Client-Info " : " supabase-swift/ \( version) " ,
142148 " Authorization " : " Bearer \( supabaseKey) " ,
143149 " Apikey " : supabaseKey,
@@ -149,7 +155,7 @@ public final class SupabaseClient: Sendable {
149155
150156 auth = AuthClient (
151157 url: supabaseURL. appendingPathComponent ( " /auth/v1 " ) ,
152- headers: defaultHeaders . dictionary,
158+ headers: _headers . dictionary,
153159 flowType: options. auth. flowType,
154160 redirectToURL: options. auth. redirectToURL,
155161 storageKey: options. auth. storageKey ?? defaultStorageKey,
@@ -167,13 +173,13 @@ public final class SupabaseClient: Sendable {
167173 _realtime = UncheckedSendable (
168174 RealtimeClient (
169175 supabaseURL. appendingPathComponent ( " /realtime/v1 " ) . absoluteString,
170- headers: defaultHeaders . dictionary,
171- params: defaultHeaders . dictionary
176+ headers: _headers . dictionary,
177+ params: _headers . dictionary
172178 )
173179 )
174180
175181 var realtimeOptions = options. realtime
176- realtimeOptions. headers. merge ( with: defaultHeaders )
182+ realtimeOptions. headers. merge ( with: _headers )
177183
178184 if realtimeOptions. logger == nil {
179185 realtimeOptions. logger = options. global. logger
0 commit comments