Skip to content

Commit

Permalink
chore(core): Allow credentials in browser environments
Browse files Browse the repository at this point in the history
This is needed to use cookies.
  • Loading branch information
dnys1 committed Mar 9, 2024
1 parent 4267fbf commit fbbc101
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/celest_core/lib/src/http/celest_http_client.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions packages/celest_core/lib/src/http/http_client.vm.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:http/http.dart' as http;

http.Client createHttpClient() {
return http.Client();
}
6 changes: 6 additions & 0 deletions packages/celest_core/lib/src/http/http_client.web.dart
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit fbbc101

Please sign in to comment.