ZengoTim
ZengoTim

Reputation: 211

CORS request will not work in Chrome

I know this question has been asked before, I have read/tried them all. I am needing to do createMediaElementSource on mp3 files stored on a different domain for visualizations. What I have works well in Safari and Edge but not in Chrome (dunno about FireFox). The issue is if I create the element from a cross-origin source using:

var audioSrc = ctx.createMediaElementSource(cfg.audio);

...where cfg.audio is cross-domain, Chrome gives me:

MediaElementAudioSource outputs zeroes due to CORS access restrictions

But I have (among other things) in my .htaccess:

Header set Access-Control-Allow-Origin: "http://the-correct-domain.com"

I have checked the header at the webconfs.com site and am getting:

HTTP/1.1 200 OK => 
Date => Fri, 09 Dec 2016 20:52:17 GMT
Server => Apache
Last-Modified => Thu, 27 Jun 2013 20:55:40 GMT
ETag => "2d60fc-4e028fc23173e"
Accept-Ranges => bytes
Content-Length => 2973948
Access-Control-Allow-Origin => http://the-correct-domain.com
Access-Control-Allow-Credentials => false
Access-Control-Allow-Methods => ACL, CANCELUPLOAD, CHECKIN, CHECKOUT, COPY, DELETE, GET, HEAD, LOCK, MKCALENDAR, MKCOL, MOVE, OPTIONS, POST, PROPFIND, PROPPATCH, PUT, REPORT, SEARCH, UNCHECKOUT, UNLOCK, UPDATE, VERSION-CONTROL
Access-Control-Allow-Headers => Overwrite, Destination, Content-Type, Depth, User-Agent, Translate, Range, Content-Range, Timeout, X-File-Size, X-Requested-With, If-modified-Since, X-File-Name, Cache-Control, location, Lock-Token
Connection => close
Content-Type => audio/mpeg

(I started with a simple Access-Control-Allow-Origin: "*" and have added crap from that point). The script works just fine using a local mp3 file, and I tried adding PHP voodoo from HERE to no avail. Where have I gone wrong?

Upvotes: 0

Views: 1097

Answers (1)

ZengoTim
ZengoTim

Reputation: 211

Got it at long last, thanks to this post. I changed the script from audio.crossOrigin = 'Anonymous' to audio.crossOrigin = 'use-credentials' and all is well. You're my hero pdg137!

Upvotes: 1

Related Questions