Why my Flutter Web App can't call the Deezer API when deployed on GitHub Pages

65 views Asked by At

I want to call the Deezer API to load songs to show. My dart Code to call the Deezer API is:


void searchForSongs(String searchString) async {
    var url = Uri.parse('https://api.deezer.com/search?q=$searchString');
    Map<String, String> requestHeaders = {
      'Content-type': 'application/json',
      'Accept': 'application/xml',
    };
    var response = await http.get(url, headers: requestHeaders);
    var body = json.decode(response.body);
    print(body);
}

When I run the app locally everything works fine. But when I deploy the app to Github Pages the code throws the Error:

[Error] XMLHttpRequest cannot load https://api.deezer.com/search?q=kk due to access control checks.

Can anyone tell me why I get this error and how I can fix it?

0

There are 0 answers