0

I am trying to make a video chat in the web browser with WebRTC following this codelab:

https://codelabs.developers.google.com/codelabs/webrtc-web/#7

My problem is that when I try to connect to localhost:8080 on another computer, I get this in the web browser console:

XMLHttpRequest cannot load https://computeengineondemand.appspot.com/turn?
username=41784574&key=4080218913. No 'Access-Control-Allow-Origin' header is
present on the requested resource. Origin 'http://192.168.1.5:8080' is
therefore not allowed access.
Marvinatorrr
  • 103
  • 1
  • 3
  • 15
  • http://stackoverflow.com/questions/28547288/no-access-control-allow-origin-header-is-present-on-the-requested-resource-err – abc123 Nov 06 '16 at 07:31
  • @JonasKöritz This is a turn server so I suspect this is different. Hard to tell without seeing any code of course. Turns servers are not free. – jib Nov 06 '16 at 15:00

1 Answers1

0

Check the network requests performed by the browser. It should start with a request of type OPTIONS.

If your server receives that, send the header field from the error message back with the domain name the user is accessing from, e.g.:

Access-Control-Allow-Origin: example.com

This is a security feature to prevent the browser from accessing your API from third party pages. It's not perfect but still prevents basic attacks and manipulation attempts.

For debugging purposes (or if you'd like anyone to use your API on any other page) you can pass the value *, which essentially disables this check.

Mario
  • 35,726
  • 5
  • 62
  • 78