Using the soundcloud API: redirecting to file:// instead of http://


#1

I am trying to use the soundcloud api to build an App that can play some of their audio files.

I am querying an URL on the server and it redirects me towards another web address, which is the desired behavior, like so:

$http({
    url: myurl,
    method: "GET",
    params: {
        param1: param1
    }
}).then(function(response) {
    // do stuff
});

When I do it in my testing browser with ionic serve, I don’t have any issue and I get the information from <redirectedUrl>: ionic has followed the redirection correctly.

When I launch ionic run android and do it on my android phone, I get a

Failed to load resource: net::ERR_FILE_NOT_FOUND  
file://<redirectedUrl>

I am assuming ionic/angular is mixing up the meaning of // somewhere… Is there a way to force the http protocole during the redirection?


#2

My bad, the problem was in the soundcloud api: they are using the current window location to deduce the protocol to use if you don’t specify it.

If anyone stumbles upon that, you have to specify

SC.stream('https://api.soundcloud.com/track/1234')

instead of

SC.stream('/track/1234')

like indicated in the doc.