Last active
June 2, 2020 12:15
-
-
Save onlyoneaman/144a96058446d3ad85aa51a284635834 to your computer and use it in GitHub Desktop.
Handling CORS in Rails app
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
module Userapi | |
class Application < Rails::Application | |
#... | |
#Rails 3/4 | |
config.middleware.insert_before 0, "Rack::Cors" do | |
allow do | |
origins '*' | |
resource '*', :headers => :any, :methods => [:get, :post, :options] | |
end | |
end | |
#Rails 5/6 | |
config.middleware.insert_before 0, Rack::Cors do | |
allow do | |
origins '*' | |
resource '*', :headers => :any, :methods => [:get, :post, :options] | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment