Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): Allow credentials in browser environments #76

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}