blob: a27662b798c5c2a49d7130afbb99a53766135e19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import 'package:dio/dio.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../api/dio_player_api_client.dart';
import '../api/player_api_client.dart';
import 'api_client_provider.dart' show kPlayerBaseUrl;
/// Provides an unauthenticated [PlayerApiClient] for public endpoints.
///
/// Unlike [apiClientProvider], this client has no bearer-token interceptor
/// and no 401 → login redirect interceptor. It is designed exclusively for
/// the share-viewer feature, where the share token is part of the URL path
/// (not an Authorization header) and no session is required.
///
/// Using a dedicated provider keeps the authenticated and public clients
/// cleanly separated (Single Responsibility, Separation of Concerns) and
/// avoids accidentally attaching a session to public requests.
final publicApiClientProvider = Provider<PlayerApiClient>((ref) {
// Minimal Dio instance: JSON content-type, same base URL as the auth client,
// but without any auth or redirect interceptors.
final dio = Dio(
BaseOptions(
baseUrl: kPlayerBaseUrl,
contentType: 'application/json',
responseType: ResponseType.json,
),
);
return DioPlayerApiClient(dio: dio);
});
|