public
Created

Handle CORS with Rails

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.