Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I avoid CORS restriction for web audio api?

I trying to create some visualization for audio-stream. But I run into CORS trouble when I try get access to raw audio data with createMediaElementSource() function.

Is there a way to avoid this restriction and get raw audio data from stream on other origins? Perhaps using WebSockets?

like image 892
Alexey Nikiforov Avatar asked Jun 02 '15 18:06

Alexey Nikiforov


1 Answers

There are five ways to deal with the protections against cross-origin retrieval:

  1. CORS headers -- this is ideal, but you need the cooperation of the third-party server
  2. JSONP -- not appropriate for streaming content and you typically need the cooperation of the third-party server
  3. Iframes and inter-window communication -- probably not appropriate for streaming content and you need the cooperation of the third-party server
  4. Turning off browser protections -- you need to be running the browser in a custom mode, and you should not use that browser for anything else
  5. Server-side proxy -- comparatively slow but often the only feasible option
like image 133
Michael Lorton Avatar answered Sep 28 '22 06:09

Michael Lorton