How to solve "No 'Access-Control-Allow-Origin' header is present"?

This question already has an answer here:

  • “No 'Access-Control-Allow-Origin' header is present on the requested resource”

    27 answers

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

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
username=41784574&key=4080218913. No 'Access-Control-Allow-Origin' header is
present on the requested resource. Origin '' is
therefore not allowed access.

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.:


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.