Created
July 10, 2014 14:53
-
-
Save jsomara/eaa2bba40aeca26fcacc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Api::BaseController < ApplicationController | |
before_filter :authenticate_user!, :except => [:options] | |
before_filter :subscribed_user, :except => [:options] | |
... | |
def options | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS' | |
headers['Access-Control-Max-Age'] = '1000' | |
headers['Access-Control-Allow-Headers'] = 'X-Requested-With,Content-Type, Cache-Control, Accept, X-CSRF-Token, Authorization, X-XSRF-Token' | |
render :json => "", :content_type => "application/json" | |
end | |
end |
This file contains hidden or 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
# CORS Configuration | |
config.middleware.insert_before Warden::Manager, Rack::Cors do | |
allow do | |
origins '*' | |
resource '*', :headers => :any, :methods => [:get, :post, :options, :delete, :put] | |
end | |
end |
This file contains hidden or 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
match "/*path" => "base#options", :via => :options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment