-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uninitialized constant Rack::Cors #26
Comments
What does your Gemfile look like? |
Hi @cyu thanks |
Try replacing the class reference w/ a string: config.middleware.use "Rack::Cors" do
allow do
origins '*'
resource '*', :headers => :any, :methods => [:get, :post, :delete, :put, :options]
end
end |
Closing this issue. Please re-open if you're still having issues. |
Having the same issue as OP, using the string doesn't work for me either. |
@arcreative Are you still having this issue? And you've re-started your app after adding the gem? |
Having the same issue in a Rails 4 app in production environment. |
@moneypenny Can you send post the Gemfile and the application.rb (or wherever you're using the middleware) |
Sorry for the delay. Here's our Gemfile:
And config/application.rb from the Rails app:
In config/environments/production.rb, we have |
Everything looks okay... I have a example app (in the examples directory) using Rails 4.1.5 and starts up okay. How about the backtrace? What does that look like? |
Try adding: require 'rack' |
+1 @akinnunen It makes sense to add those requires before |
@akinnunen @mcka1n |
Your bug happens to be my solution, odd enough :) |
You just need to un-comment the Rack CORS gem in your Gemfile (gemfile.rb) # gemfile.rb And then run the code below to install the gem And also ensure that your cors initializer (cors.rb) is set this way
Setting origins to '*' should be alright for development, but keep in mind that if you deploy to production you’ll want to change this value to match your front-end’s URI for security reasons. Hope this helps |
I'm closing this issue because there hasn't been any activity on this issue in a while. |
I'm having an issue when starting up my server with shotgun: LoadError: cannot load such file -- rack/cors |
I'm having this issue too and this code resolv for me. ` if app_urls.present? Rails.application.config.middleware.insert_before 0, Rack::Cors do
end |
I'm having this issue when running a rails 3.2.12 app, it is running with unicorn on production environment
Here is the unicorn log.
In my
Gemfile
I've addedIn my
config/application.rb
I've addedI'd already tryied
require 'rack/cors'
in my `config/application.rb'The text was updated successfully, but these errors were encountered: