I want to post data to the server with dio library but when I send data, I get XMLHttpRequest error
. The server programmer checked twice his codes and made sure to enable CORS in the server. I think this error occurs because the server is not HTTPS
and the browser blocks the request. I use this code to send my data to the server:
Response response = await client
.post(theUrl,
options: Options(
validateStatus: (status) {
return status! < 500;
},
followRedirects: false,
headers: {
HttpHeaders.contentTypeHeader: "application/json",
HttpHeaders.acceptHeader: "*/*",
HttpHeaders.accessControlAllowOriginHeader:
"Access-Control-Allow-Origin, Accept",
}),
data: convert.json.encode(data))
.timeout(const Duration(seconds: 10));
My log is just:
DioError [DioErrorType.RESPONSE]: XMLHttpRequest error.
So, How can I ignore the certificate of the server host and send data to an HTTP URL in flutter web?