mirror of
https://github.com/yattee/yattee.git
synced 2026-05-13 02:45:03 +00:00
Inject basic auth via per-instance HTTPClient default headers
Replace the YatteeServerAPI setAuthHeader/buildHeaders pattern (which was race-prone on the shared actor across multiple instances) with a generic mechanism: HTTPClient now supports a defaultHeaders dictionary applied to every request, and ContentService builds a per-instance HTTPClient with the basic-auth Authorization header baked in whenever credentials are configured. The same code path now works uniformly for Invidious, Piped, PeerTube, and Yattee Server, so any instance sitting behind a reverse proxy that requires HTTP Basic Auth can be authenticated regardless of backend type. Cached default API actors are still reused when no basic-auth header is needed.
This commit is contained in:
@@ -438,9 +438,11 @@ struct ManageChannelsView: View {
|
||||
guard !channelIDs.isEmpty else { return }
|
||||
|
||||
do {
|
||||
let api = YatteeServerAPI(httpClient: HTTPClient())
|
||||
let authHeader = appEnvironment.basicAuthCredentialsManager.basicAuthHeader(for: yatteeServer)
|
||||
await api.setAuthHeader(authHeader)
|
||||
let httpClient = HTTPClient()
|
||||
if let authHeader = appEnvironment.basicAuthCredentialsManager.basicAuthHeader(for: yatteeServer) {
|
||||
await httpClient.setDefaultHeaders(["Authorization": authHeader])
|
||||
}
|
||||
let api = YatteeServerAPI(httpClient: httpClient)
|
||||
let response = try await api.channelsMetadata(channelIDs: channelIDs, instance: yatteeServer)
|
||||
|
||||
// Update subscriptions in SwiftData
|
||||
|
||||
Reference in New Issue
Block a user