简体   繁体   中英

Why am I getting No such middleware to insert before: "ActionDispatch::Static" (RuntimeError)

Here is my Gem file. I am thinking its some sort of order of things in the gem file?

Environments/ files are

config.serve_static_files = false

GEM FILE

source 'https://rubygems.org'
ruby '2.5'
gem 'rails', '5.2.0'
gem 'mongo', '2.10.0'
gem 'bson_ext'
gem 'mongoid', '~> 7.0.5'
# mongoid seemed to want these to run the generator
gem 'execjs'
#gem 'therubyracer'
gem 'devise'
gem 'grape'
# gem 'activemodel', '~> 5.1'
# gem 'actionpack', '~> 5.1.0'
#gem 'grape-swagger'
#gem 'thin'
#gem 'puma'
gem 'geocoder'
#gem 'mongoid_geospatial'
gem 'kaminari' # pagination
gem 'iron_worker_ng'
gem 'kaminari-mongoid'
gem 'newrelic_rpm'
gem 'newrelic-grape'
gem "opentok", "~> 2.2"
gem 'mandrill-api'
gem 'aws-sdk', "~> 1"
gem 'nexmo'
gem 'rmagick'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem 'twilio-ruby'
gem 'gcm'
gem 'chronic'
gem 'oauth2' # for stripe connect
gem 'houston'
gem 'hashids'
gem 'rack-cors', :require => 'rack/cors'
gem 'mail'
gem 'sendgrid-ruby', "~> 5.3.0"

group :production, :staging do
  gem 'rails_12factor'
  gem "puma"
  #gem 'thin'
end

group :development, :test do
  gem 'factory_girl_rails'
  gem 'timecop'
  #gem 'debugger'
  gem 'typhoeus'
  #gem 'thin'
  #gem "puma"
  #gem 'rbnacl'
end

# Gems used only for assets and not required
# in production environments by default.
#group :assets do
#  gem 'sass-rails'
#  gem 'coffee-rails'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

#  gem 'uglifier'
#end
gem 'uglifier'
gem 'jquery-rails'

It appears maybe this middleware in the application.rb file might be the issue?

config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors" do
      allow do
        origins '*'
        resource '*', :headers => :any, :methods => [:get, :post, :options]
      end
    end

If I comment out the above code then I get this error?

/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/actionpack-5.2.0/lib/action_dispatch/middleware/ssl.rb:59:in `initialize': unknown keyword: exclude (ArgumentError)

gem 'rails_12factor', '~> 0.0.3'我遇到了同样的挑战,这个在生产中添加的 gem 帮助我解决了这个问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM