@@ -36,7 +36,7 @@ public final class SupabaseClient: Sendable {
36
36
$0. rest = PostgrestClient (
37
37
url: databaseURL,
38
38
schema: options. db. schema,
39
- headers: defaultHeaders . dictionary ,
39
+ headers: headers ,
40
40
logger: options. global. logger,
41
41
fetch: fetchWithAuth,
42
42
encoder: options. db. encoder,
@@ -55,7 +55,7 @@ public final class SupabaseClient: Sendable {
55
55
$0. storage = SupabaseStorageClient (
56
56
configuration: StorageClientConfiguration (
57
57
url: storageURL,
58
- headers: defaultHeaders . dictionary ,
58
+ headers: headers ,
59
59
session: StorageHTTPSession ( fetch: fetchWithAuth, upload: uploadWithAuth) ,
60
60
logger: options. global. logger
61
61
)
@@ -77,7 +77,7 @@ public final class SupabaseClient: Sendable {
77
77
if $0. functions == nil {
78
78
$0. functions = FunctionsClient (
79
79
url: functionsURL,
80
- headers: defaultHeaders . dictionary ,
80
+ headers: headers ,
81
81
region: options. functions. region,
82
82
logger: options. global. logger,
83
83
fetch: fetchWithAuth
@@ -88,7 +88,13 @@ public final class SupabaseClient: Sendable {
88
88
}
89
89
}
90
90
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
+ }
92
98
93
99
struct MutableState {
94
100
var listenForAuthEventsTask : Task < Void , Never > ?
@@ -137,7 +143,7 @@ public final class SupabaseClient: Sendable {
137
143
databaseURL = supabaseURL. appendingPathComponent ( " /rest/v1 " )
138
144
functionsURL = supabaseURL. appendingPathComponent ( " /functions/v1 " )
139
145
140
- defaultHeaders = HTTPHeaders ( [
146
+ _headers = HTTPHeaders ( [
141
147
" X-Client-Info " : " supabase-swift/ \( version) " ,
142
148
" Authorization " : " Bearer \( supabaseKey) " ,
143
149
" Apikey " : supabaseKey,
@@ -149,7 +155,7 @@ public final class SupabaseClient: Sendable {
149
155
150
156
auth = AuthClient (
151
157
url: supabaseURL. appendingPathComponent ( " /auth/v1 " ) ,
152
- headers: defaultHeaders . dictionary,
158
+ headers: _headers . dictionary,
153
159
flowType: options. auth. flowType,
154
160
redirectToURL: options. auth. redirectToURL,
155
161
storageKey: options. auth. storageKey ?? defaultStorageKey,
@@ -167,13 +173,13 @@ public final class SupabaseClient: Sendable {
167
173
_realtime = UncheckedSendable (
168
174
RealtimeClient (
169
175
supabaseURL. appendingPathComponent ( " /realtime/v1 " ) . absoluteString,
170
- headers: defaultHeaders . dictionary,
171
- params: defaultHeaders . dictionary
176
+ headers: _headers . dictionary,
177
+ params: _headers . dictionary
172
178
)
173
179
)
174
180
175
181
var realtimeOptions = options. realtime
176
- realtimeOptions. headers. merge ( with: defaultHeaders )
182
+ realtimeOptions. headers. merge ( with: _headers )
177
183
178
184
if realtimeOptions. logger == nil {
179
185
realtimeOptions. logger = options. global. logger
0 commit comments