Created
May 4, 2014 15:20
-
-
Save simonmorley/24f1492e8515d1038d29 to your computer and use it in GitHub Desktop.
Public API Cors Before Filter Rails API
This file contains 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
before_filter: cors_filters | |
def cors_filters | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shove this in a controller to allow cors requests in a Ruby on Rails application.
We use for the interface with an AngularJS application.