Closed maksym-tielnyi-solid closed 1 year ago
You need to follow the dart edge documentation. Specifically, you need a custom http client. Either like in the example from the website:
import 'package:edge_http_client/edge_http_client.dart';
import 'package:http/http.dart' as http;
http.runWithClient(() async {
// Haven't tested this though
Supabase.initialize();
}, () => EdgeHttpClient());
or simply pass EdgeHttpClient()
as httpClient
to Supabase.initialize()
.
This is also shown in the supabase documentation
@Vinzent03 do you mean SupabaseClient
instead of Supabase.initialize()
? Because the Edge function fails to build when I import supabase_flutter
package that contains the Supabase
class.
I passed EdgeHttpClient
to the SupabaseClient
constructor, as it is shown in the Supabase documentation and it worked fine until one of the latest updates of the supabase
package (probably 1.11.9 or so).
I tried to use runWithClient
as you suggested and it didn't help as well.
I found that the latest version of realtime_client
caused the issue. I added dependency override to 1.2.3
and now Edge functions work fine.
dependency_overrides:
realtime_client: 1.2.3
Describe the bug The
SupabaseClient
constructor throws"Cannot create a client without dart:html or dart:io."
error when used in Dart Edge functions. An error message looks like the following:To Reproduce
main.dart
:pubspec.yaml
:Steps to reproduce the behavior:
dart_edge
function using Postman/curl/etc.Internal Server Error
response and an error message in the functions console.Version: supabase_flutter_test 1.0.0 ├── supabase 1.11.9 │ ├── functions_client 1.3.2 │ ├── gotrue 1.12.4 │ ├── postgrest 1.5.1 │ ├── realtime_client 1.3.0 │ ├── storage_client 1.5.3 └── supabase_functions 0.0.2+4
Additional context
flutter doctor
output: