How to get rid of Cross-Origin Request Blocked: in rails 4
<p>Can you please tell me where I have gone wrong and is there anything left out that I has to add to fetch the json from heroku site</p>

<p>config.ru</p>

<pre><code>require ::File.expand_path('../config/environment', __FILE__)

run Rails.application
use Rack::Cors do
allow do
origins 'localhost:3000', '127.0.0.1:3000', 'http://stark-anchorage-86169.herokuapp.com/ages/    getfortest', /\Ahttp:\/\/192\.168\.0\.\d{1,3}(:\d+)?\z/


resource '/file/list_all/', :headers =&gt; 'x-domain-token'
resource '/file/at/*',
    :methods =&gt; [:get, :post, :delete, :put, :patch, :options, :head],
    :headers =&gt; 'x-domain-token',
    :expose  =&gt; ['Some-Custom-Response-Header'],
    :max_age =&gt; 600

end

 allow do
 origins '*'
 resource '/public/*', :headers =&gt; :any, :methods =&gt; :get
 end
 end
</code></pre>

<p>config/application.rb</p>

<pre><code>Bundler.require(*Rails.groups)

module AppV11
class Application &lt; Rails::Applications.



config.active_record.raise_in_transactional_callbacks = true

config.middleware.insert_before 0, "Rack::Cors" do
  allow do
    origins '*'
    resource '*', :headers =&gt; :any, :methods =&gt; [:get, :post, :options]
  end
end
end

end
</code></pre>

<p>My Controller looks like this with some helpers below</p>

<pre><code>before_filter :set_access_control_headers

def set_access_control_headers
headers['Access-Control-Allow-Origin'] = 'http://staranchorage-          86169.herokuapp.com/ages/getfortest'
end
</code></pre>

<p>The Angularjs part:</p>

<pre><code>function getpost()
 {
     console.log("INSIDE GETPOST");
     $http.get('http://stark-anchorage-86169.herokuapp.com/ages/getfortest')
     .success(function(response)
             {
         console.log("INSIDE RESPONSE "+ response);
         $scope.demogetpost = response.data;
         console.log( $scope.demogetpost);
         console.log("NOT PRINTING");
     })
     return $scope.demogetpost;
 }
</code></pre>