Skip to content

Instantly share code, notes, and snippets.

@benshimmin
Created April 10, 2012 06:15
Show Gist options
  • Save benshimmin/2348702 to your computer and use it in GitHub Desktop.
Save benshimmin/2348702 to your computer and use it in GitHub Desktop.
Sinatra and cross-domain origins for local testing
# If you have a local test environment with a server running on (say) http://localhost:8888/
# and are also using Sinatra running on http://localhost:4567/ then you will most likely run
# into cross-domain problems communicating between the two via JavaScript. Here's a quick
# fix that will work beautifully for your local testing environment _but you should not use
# otherwise_!
require "sinatra"
before do
headers "Access-Control-Allow-Origin" => "*"
end
get "/" do
"Everything works like a charm now!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment