I have a big problem that makes me late on my project I have the CROS problem that blocks my requests I can't correct it, I added in my .htacess the lines below, but it doesn't work I can't understand it
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://maps.googleapis.com/maps/api/place/autocomplete/json…nents=country:fr&key=MY_KEY. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.kosmos-digital.com/$1 [R,L]
Rewritecond %{HTTP_HOST} ^kosmos-digital.com$
Rewriterule ^(.*) https://www.kosmos-digital.com/$1 [QSA,L,R=301]
<ifModule mod_headers.c>
SetEnvIf Origin "http(s)?://(www.kosmos-digital.com|www.maps.googleapis.com)$" AccessControlAllowOrigin=$0
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
Header always set Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
</ifModule>
I don't think it's from my code, but I'll put it underneath :
try {
await Dio().get<String>("https://maps.googleapis.com/maps/api/place/autocomplete/json?input=28%20avenue%20pierre%20corneille&language=fr&components=country:fr&key=MY_KEY").then((e) {
print(e.data);
}).catchError(print);
// Map<String, dynamic> dataAsJson = await HttpUtils.getForJson(url, headers: headers);
// print(dataAsJson.toString());
} catch(e) {
print(e.toString());
}