Configure Dio with BrowserHttpClientAdapter and withCredentials: true for web platform, allowing session cookies to be sent with XHR requests. This fixes NPM forward auth not working for API calls. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
13 lines
439 B
Dart
13 lines
439 B
Dart
import 'package:dio/dio.dart';
|
|
import 'package:dio_web_adapter/dio_web_adapter.dart';
|
|
|
|
/// Create a Dio instance for web platform with credentials support.
|
|
///
|
|
/// Enables `withCredentials` to send cookies with requests, which is
|
|
/// required for NPM forward auth to work correctly.
|
|
Dio createDio(BaseOptions options) {
|
|
final dio = Dio(options);
|
|
dio.httpClientAdapter = BrowserHttpClientAdapter(withCredentials: true);
|
|
return dio;
|
|
}
|