Created
April 10, 2012 06:15
-
-
Save benshimmin/2348702 to your computer and use it in GitHub Desktop.
Sinatra and cross-domain origins for local testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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