Announcements

Help Wizard

Step 1

NEXT STEP

Cross-Origin Request Blocked: CORS request did not succeed

Cross-Origin Request Blocked: CORS request did not succeed

Hi, I'm currently having an issue where any Spotify API requests I send from client-side JavaScript are resulting in CORS errors. For example, a request to get a user's saved tracks would result in the following error:

 

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.spotify.com/v1/me/tracks?offset=0&limit=50. (Reason: CORS request did not succeed).

 

The code (example snippet below) is running on GitHub Pages, which does have the access-control-allow-origin: * header needed to allow such requests, so I'm not sure what the problem is. If I try to send the same request from server-side NodeJS code or through API testing software such as Insomnia it goes through just fine, but I need to be able to send the request without the use of a server for this particular app.

 

axios.get("https://api.spotify.com/v1/me/tracks?offset=0&limit=50", {
    headers: {
        Authorization: "token here (removed for post)"
    },
});

 

I've tried everything I could think of, any help would be much appreciated.

Reply
0 Replies

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random