Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMLHttpRequest Cross origin requests are only supported for protocol schemes in turn server

I am getting a below error in chrome console

XMLHttpRequest cannot load XMLHttpRequest cannot load turn:global.turn.twilio.com:3478/turn?username=username&key=key&transport=udp Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

while running a local webrtc sample server The node server example i am running is from https://github.com/ISBX/apprtc-node-server/

Below is the enter image description herescreenshot

Thanks in advance

like image 875
bladeX Avatar asked May 02 '17 12:05

bladeX


People also ask

Is it possible to access XMLHttpRequest from origin'null'?

xml.html: 27 Access to XMLHttpRequest at 'file:///C:/Users/1819092/Desktop/MANAS/ajax_info.txt' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. If you have a question then use the red "Ask a Question" link at the top of the page.

Can I make cross-origin requests on behalf of a content script?

When performing cross-origin requests on behalf of a content script, be careful to guard against malicious web pages that might try to impersonate a content script. In particular, do not allow content scripts to request an arbitrary URL.

What is the origin of a request?

The origin is a URL indicating the server from which the request initiated. It does not include any path information, but only the server name. The origin value can be null. Note that in any access control request, the Origin header is always sent.

What is the origin policy for content scripts?

Content scripts initiate requests on behalf of the web origin that the content script has been injected into and therefore content scripts are also subject to the same origin policy. (Content scripts have been subject to CORB since Chrome 73 and CORS since Chrome 83 .)


1 Answers

I believe you have a misunderstanding of what a TURN server is for, and are calling it as if it is a standard web server.

As some of the commenters mentioned, you're not supposed to make an HTTP request to a TURN server, which uses a different TURN protocol. Instead, you configure your WebRTC setup via the iceServer object, which is where you define a TURN server. The WebRTC implementation will use the TURN servers when required.

Here's a nice article about WebRTC signaling:

https://www.html5rocks.com/en/tutorials/webrtc/infrastructure/

And here's a couple other articles if you're interested in learning about the specific protocols WebRTC uses:

https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Protocols

https://www.twilio.com/docs/api/stun-turn/faq

like image 117
Michael Avatar answered Oct 02 '22 20:10

Michael