I'm trying to access a Heroku app that I'm running at
young-dusk-4185.herokuapp.com
However, when trying to access the response on this link, I get the No 'Access-Control-Allow-Origin
headers present` error. Referring to another question, I've added
response.headers['Access-Control-Allow-Origin'] = '*'
to my Ruby file as follows:
require 'sinatra'
require './test.rb'
get '/' do
result = FooRunner.run!
File.open('output.json','w') do |f|
f.write result
end
response.headers['Access-Control-Allow-Origin'] = '*'
content_type :json
result
end
When I tested it on fiddle, http://jsfiddle.net/Newtt/wF3ca/1/, the call fails. In the current fiddle method is GET
. I've even tried with POST
but that fails as well. The fiddle code was taken from this question:
How do I send a cross-domain POST request via JavaScript?
Any idea how to acquire the JSON response from the app? Any code examples will be appreciated. Thank you!