Skip to content

Instantly share code, notes, and snippets.

@olistik
Created February 13, 2013 09:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olistik/4943295 to your computer and use it in GitHub Desktop.
Save olistik/4943295 to your computer and use it in GitHub Desktop.
Handle CORS with Rails
# application_controller.rb
before_filter :handle_cors
def handle_cors
if env.keys.include? "HTTP_ORIGIN"
response.headers['Access-Control-Allow-Origin'] = 'http://www.myapp.com'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment