Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing cross origin error in access of another domain mp3 files tags #64

Open
php07magic opened this issue Nov 14, 2018 · 1 comment
Open

Comments

@php07magic
Copy link

I am trying to fetch all tags data like album name, artist, song image etc from amazon server. Here is one URL of song that I am passing https://s3.amazonaws.com/clueradiomedia/music/%24uicideBoy%24/Either%20Hated%20Or%20Ignored%20-%20Single/Either%20Hated%20Or%20Ignored.mp3

var customurl = 'https://s3.amazonaws.com/clueradiomedia/music/%24uicideBoy%24/Either%20Hated%20Or%20Ignored%20-%20Single/Either%20Hated%20Or%20Ignored.mp3';

ID3.loadTags(customurl, function() {

    var getfile = customurl;
	var tags = ID3.getAllTags(getfile);
	
	console.log(tags);
	
	alert(tags.artist + " - " + tags.title + ", " + tags.album);

	var image = tags.picture;
	if (image) {
		var base64String = "";
		for (var i = 0; i < image.data.length; i++) {
			base64String += String.fromCharCode(image.data[i]);
		}
		var base64 = "data:" + image.format + ";base64," +
				window.btoa(base64String);
		document.getElementById('picture').setAttribute('src',base64);
	  } else {
		document.getElementById('picture').style.display = "none";
	  }
},{
    tags: ["title","artist","album","picture", "year", "comment", "track", "genre", "lyrics"],
  });

But, when I am hitting above function then its showing me this error "Access to XMLHttpRequest at 'http://s3.amazonaws.com/clueradiomedia/music/%24uicideBoy%24/Either%20Hated%20Or%20Ignored%20-%20Single/Either%20Hated%20Or%20Ignored.mp3' from origin 'http://----' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."

I am checking the main file but its minified so I can't deduct how to pass request headers for XML request.

Can please suggest me how to pass allow origin headers here?

Thanks!

@aadsm
Copy link
Owner

aadsm commented Nov 20, 2018

Hey @php07magic,

CORS is something that is configured on the server, not on the client. The server needs to send the Access-Control-Allow-Origin so the browser knows it’s fine to connect to it.
I haven’t used amazon to store files myself but I’d imagine it should be possible to configure that. They talk about it here: https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants