Skip to content

Instantly share code, notes, and snippets.

@raphaklaus
Created March 7, 2015 13:01
Show Gist options
  • Save raphaklaus/645d298d79d5c96824af to your computer and use it in GitHub Desktop.
Save raphaklaus/645d298d79d5c96824af to your computer and use it in GitHub Desktop.
Ruby on Rails CORS
class ApplicationController < ActionController::API
after_filter :cors
def cors
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'OPTIONS, POST, DELETE, GET, PUT'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept'
headers['Access-Control-Max-Age'] = '1728000'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment