diff --git a/packages/celest_core/lib/src/http/celest_http_client.dart b/packages/celest_core/lib/src/http/celest_http_client.dart index e276eb9f..c8c33d66 100644 --- a/packages/celest_core/lib/src/http/celest_http_client.dart +++ b/packages/celest_core/lib/src/http/celest_http_client.dart @@ -1,5 +1,7 @@ import 'dart:isolate'; +import 'package:celest_core/src/http/http_client.vm.dart' + if (dart.library.js_interop) 'package:celest_core/src/http/http_client.web.dart'; import 'package:celest_core/src/storage/secure/secure_storage.dart'; import 'package:celest_core/src/storage/storage.dart'; import 'package:celest_core/src/util/globals.dart'; @@ -11,7 +13,7 @@ final class CelestHttpClient extends http.BaseClient { http.Client? baseClient, }) : _secureStorage = secureStorage, _ownsInner = baseClient == null, - _inner = baseClient ?? http.Client(); + _inner = baseClient ?? createHttpClient(); final SecureStorage _secureStorage; final bool _ownsInner; diff --git a/packages/celest_core/lib/src/http/http_client.vm.dart b/packages/celest_core/lib/src/http/http_client.vm.dart new file mode 100644 index 00000000..e96f5b64 --- /dev/null +++ b/packages/celest_core/lib/src/http/http_client.vm.dart @@ -0,0 +1,5 @@ +import 'package:http/http.dart' as http; + +http.Client createHttpClient() { + return http.Client(); +} diff --git a/packages/celest_core/lib/src/http/http_client.web.dart b/packages/celest_core/lib/src/http/http_client.web.dart new file mode 100644 index 00000000..584c1175 --- /dev/null +++ b/packages/celest_core/lib/src/http/http_client.web.dart @@ -0,0 +1,6 @@ +import 'package:http/browser_client.dart' as http; +import 'package:http/http.dart' as http; + +http.Client createHttpClient() { + return http.BrowserClient()..withCredentials = true; +}