Skip to content

Instantly share code, notes, and snippets.

@parano
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parano/3ccaeeb5974564f8132d to your computer and use it in GitHub Desktop.
Save parano/3ccaeeb5974564f8132d to your computer and use it in GitHub Desktop.
Ruby on Rails Controller - Allow Origin Header
class ApplicationController < ActionController::Base
before_filter :cors_set_access_control_header
# other staff
private
def cors_set_access_control_header
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment