title: Testing Rails API with AngularJS and Codepen
body: <p>Having some trouble getting my pen to talk to my dev server on localhost.</p>
  
  <p>I have an angularjs script which is using an $http.get request to get some json from the server, but it results in this error.</p>
  
  <pre><code>Access to XMLHttpRequest at 'localhost:3000/test' from origin 'https://s.codepen.io' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
  </code></pre>
  
  <p>The Rails server and the browser are on the same machine, and I can call the page successfully if I just type the server url direclty into the browser, but I'm not sure how to address this error for scripts running in codepen.   </p>
  
  <p>In case of interest the request in my javascript is just:</p>
  
  <pre><code>$http.get("localhost:3000/test").then(
     function(response) {
       console.log("success");
     },
     function(response) {
        console.log("failed");
     }
   );
  </code></pre>