No 'Access-Control-Allow-Origin' header is present on the requested resource. Firebase hosting

Viewed 101

i have app in flutter web to get Currency

i use freeforexapi api to get resulte but i got this error


Access to XMLHttpRequest at 'https://www.freeforexapi.com/api/live?pairs=USDTRY' from origin 'https://kira-contract.web.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

========================================================================

there my code

 http.Response res = await http.get('https://www.freeforexapi.com/api/live?pairs=${pairs}',
        headers: {
          'Access-Control-Allow-Origin': "*",
          'Access-Control-Allow-Methods': 'GET, POST, PATCH, DELETE, PUT, OPTIONS',
          "User-Agen":
          "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36",
          "Accept": "application/json, text/javascript, */*; q=0.01",
          'Access-Control-Allow-Headers': 'Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With',
          'Access-Control-Allow-Credentials' : 'true',

        });
    if(res.statusCode == 200){
      print(res.body);
    }else{
      print('error');
    }
0 Answers
Related