I have working with Flutter DIO Library.
Its working fine on my Android App but giving error on Web.
Error: DioError [DioErrorType.response]: XMLHttpRequest error.
If I tried same url with http its working fine for Web. My Dio Library code
Dio dio = Dio();
dio.options.method = "POST";
dio.options.headers["Access-Control-Allow-Origin"] = "*";
dio.options.headers["Access-Control-Allow-Credentials"] = true;
dio.options.headers["Access-Control-Allow-Headers"] =
"Origin,Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,locale";
dio.options.headers["Access-Control-Allow-Methods"] =
"GET, HEAD, POST, OPTIONS";
var response = await dio
.post('http://45.79.124.182/app_php/PagarGuru_test/requestAdd.php');
Error Logs
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 908:28 get current
packages/dio/src/dio_mixin.dart 819:20 assureDioError
packages/dio/src/dio_mixin.dart 678:13 _dispatchRequest
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 60:31 <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1692:54 runBinary
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 175:22 handleError
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 779:46 handleError
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 800:13 _propagateToListeners
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 610:5 [_completeError]
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/future_impl.dart 666:7 callback
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15 <fn>
at Object.throw_ [as throw] (http://localhost:58438/dart_sdk.js:5374:11)
at http://localhost:58438/packages/dio/src/interceptors/log.dart.lib.js:1390:21
at _RootZone.runBinary (http://localhost:58438/dart_sdk.js:40508:58)
at _FutureListener.catchError.handleError (http://localhost:58438/dart_sdk.js:35445:33)
at handleError (http://localhost:58438/dart_sdk.js:36033:51)
at Function._propagateToListeners (http://localhost:58438/dart_sdk.js:36059:17)
at _Future.new.[_completeError] (http://localhost:58438/dart_sdk.js:35905:23)
at _SyncCompleter.new.[_completeError] (http://localhost:58438/dart_sdk.js:35363:36)
at _SyncCompleter.new.completeError (http://localhost:58438/dart_sdk.js:35286:29)
at onError (http://localhost:58438/dart_sdk.js:35131:60)
at _RootZone.runBinary (http://localhost:58438/dart_sdk.js:40508:58)
at _FutureListener.then.handleError (http://localhost:58438/dart_sdk.js:35445:33)
at handleError (http://localhost:58438/dart_sdk.js:36033:51)
at Function._propagateToListeners (http://localhost:58438/dart_sdk.js:36059:17)
at _Future.new.[_completeError] (http://localhost:58438/dart_sdk.js:35905:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:58438/dart_sdk.js:35944:31)
at Object._microtaskLoop (http://localhost:58438/dart_sdk.js:40808:13)
at _startMicrotaskLoop (http://localhost:58438/dart_sdk.js:40814:13)
at http://localhost:58438/dart_sdk.js:36279:9
I tried other forum answer, but its not helpful.
My whole project is based on Dio Library.
What should I do?