Answers for "xmlhttprequest error flutter"

1

xmlhttprequest error flutter

this worked for me, I added the below header on the lambda function

return {
    statusCode: 200,
     headers: {
  "Access-Control-Allow-Origin": "*", // Required for CORS support to work
  "Access-Control-Allow-Credentials": true, // Required for cookies, authorization headers with HTTPS
  "Access-Control-Allow-Headers": "Origin,Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,locale",
  "Access-Control-Allow-Methods": "POST, OPTIONS"
},
    body: JSON.stringify(item)
};
Posted by: Guest on March-20-2021
2

xmlhttprequest error flutter

// Get your local IP by ipconfig (command prompt)
// XAMPP Apache 2.4 httpd.conf:
<Directory />
    Require local
    Require ip 192.168.0
</Directory>
// Flutter side: add headers to async method:
var response = await http.get(Uri.parse("http://192.168.0.54/api.php"),
  headers: {
    "Accept": "application/json",
    "Access-Control-Allow-Origin": "*"
  });
// php side (api.php):
<?php		// Modify header too
header('Content-Type: application/json');
header("Access-Control-Allow-Origin: *");		// CORS
header("Access-Control-Allow-Headers: Access-Control-Allow-Origin, Accept");
echo json_encode(['id' => '33', 'success' => 'OK']);
?>
Posted by: Guest on May-22-2021
0

IN Flutter Web getting ‘XMLHttpRequest’ error while making HTTP call

[Solved] IN Flutter Web getting ‘XMLHttpRequest’ error while making HTTP call
Posted by: Guest on June-28-2021

Code answers related to "Dart"

Browse Popular Code Answers by Language