question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Really weird (No route matches [OPTIONS]) error.

See original GitHub issue

Hi guys,

i’m using rails-api with devise-token-auth and rack-cors but I’ve experienced a really strange issue so far. I’m kind of stuck in here, could you help me?

Here is my rake middleware output

[llaine@localhost api2] $ bundle exec rake middleware
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00555c908f9700>
use Rack::Runtime
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use WebConsole::Middleware
use ActionDispatch::DebugExceptions
use BetterErrors::Middleware
use Rollbar::Middleware::Rails::RollbarMiddleware
use ActionDispatch::RemoteIp
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::Migration::CheckPending
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::ParamsParser
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
use Warden::Manager
use Rack::Cors
run NmyApi::Application.routes
ActionController::RoutingError (No route matches [OPTIONS] "/auth/sign_in"):

Here is my application.rb


module NmyApi
  class Application < Rails::Application
    config.middleware.use Rack::Cors do
      allow do
        origins '*'
        resource '*',
                 :headers => :any,
                 :expose  => ['access-token', 'expiry', 'token-type', 'uid', 'client'],
                 :methods => [:get, :post, :options, :delete, :put, :patch]
      end
    end
 end
end

Gemfile

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'

gem 'rails-api'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'

# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'active_model_serializers'

gem 'pg'

gem 'puma'

gem 'sidekiq'

gem "mini_magick"

gem 'oj'

gem 'oj_mimic_json'

gem 'activerecord-postgis-adapter'

gem 'geocoder'

gem 'kaminari'

gem 'figaro'

gem 'devise_token_auth'

gem 'omniauth'

gem 'paperclip'

gem 'foreman'

gem 'activerecord-import', '~> 0.4.0'

gem "skylight"

gem "rollbar"

gem 'rack-cors', :require => 'rack/cors'

gem 'faker', '~> 1.6.3'

group :development do
  gem 'better_errors'
  gem 'mailcatcher'

  gem 'pry'
  gem 'pry-rails'
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

And routes.rb

Rails.application.routes.draw do
  root :to => 'application#index'

  mount_devise_token_auth_for 'User', at: 'auth'

  namespace :v1 do
  ...
  end
end

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
devtorocommented, Jan 23, 2018

I have the same issue. The thing is that it is working as expected in development and production env, but in staging which has similar configuration to the production env I get the error.

Here is my configuration for cors:

config.middleware.insert_before 0, Rack::Cors do allow do origins '[host_name]' resource '*', :headers => :any, :methods => [:put, :patch, :delete, :get, :post, :options] end end

Here are also the logs from puma:

I, [2018-01-23T14:56:20.890128 #15303] INFO -- : [c275be97-8c2d-4152-962c-af6c521c0183] Started OPTIONS "/users/sign_in" for 94.65.102.218 at 2018-01-23 14:56:20 +0000 F, [2018-01-23T14:56:20.893478 #15303] FATAL -- : [c275be97-8c2d-4152-962c-af6c521c0183] F, [2018-01-23T14:56:20.893559 #15303] FATAL -- : [c275be97-8c2d-4152-962c-af6c521c0183] ActionController::RoutingError (No route matches [OPTIONS] "/users/sign_in"): F, [2018-01-23T14:56:20.893598 #15303] FATAL -- : [c275be97-8c2d-4152-962c-af6c521c0183] F, [2018-01-23T14:56:20.893643 #15303] FATAL -- : [c275be97-8c2d-4152-962c-af6c521c0183] actionpack (5.0.6) lib/action_dispatch/middleware/debug_exceptions.rb:53:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] actionpack (5.0.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] railties (5.0.6) lib/rails/rack/logger.rb:36:in ```call_app' [c275be97-8c2d-4152-962c-af6c521c0183] railties (5.0.6) lib/rails/rack/logger.rb:24:in ```block in call' [c275be97-8c2d-4152-962c-af6c521c0183] activesupport (5.0.6) lib/active_support/tagged_logging.rb:69:in ```block in tagged' [c275be97-8c2d-4152-962c-af6c521c0183] activesupport (5.0.6) lib/active_support/tagged_logging.rb:26:in ```tagged' [c275be97-8c2d-4152-962c-af6c521c0183] activesupport (5.0.6) lib/active_support/tagged_logging.rb:69:in ```tagged' [c275be97-8c2d-4152-962c-af6c521c0183] railties (5.0.6) lib/rails/rack/logger.rb:24:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] actionpack (5.0.6) lib/action_dispatch/middleware/request_id.rb:24:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] rack (2.0.3) lib/rack/runtime.rb:22:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] activesupport (5.0.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] actionpack (5.0.6) lib/action_dispatch/middleware/executor.rb:12:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] rack (2.0.3) lib/rack/sendfile.rb:111:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] rack-cors (0.4.1) lib/rack/cors.rb:81:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] railties (5.0.6) lib/rails/engine.rb:522:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] rack-cors (0.4.1) lib/rack/cors.rb:81:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] puma (3.9.1) lib/puma/configuration.rb:224:in ```call' [c275be97-8c2d-4152-962c-af6c521c0183] puma (3.9.1) lib/puma/server.rb:602:in ```handle_request' [c275be97-8c2d-4152-962c-af6c521c0183] puma (3.9.1) lib/puma/server.rb:435:in ```process_client' [c275be97-8c2d-4152-962c-af6c521c0183] puma (3.9.1) lib/puma/server.rb:299:in ```block in run' [c275be97-8c2d-4152-962c-af6c521c0183] puma (3.9.1) lib/puma/thread_pool.rb:120:in ```block in spawn_thread'

I have tried the “solution” from #106, but again my front-end application ( developed with Ember 2.14 ) did not comply with response.

Same thing happens if I set origins to “*”…

Any ideas?

1reaction
llainecommented, Jun 18, 2016

I’ve changed to config.middleware.use Rack::Cors do rebuild my app (i’m using docker to deploy) and now everything works fine so. I guess it was more docker-compose related.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RoutingError (No route matches [OPTIONS] "/users" when ...
Having issue when trying to POST data to Rails server from my AngularJS side. The server error:
Read more >
Developers - Really weird (No route matches [OPTIONS]) error. -
Hi guys,. i'm using rails-api with devise-token-auth and rack-cors but I've experienced a really strange issue so far.
Read more >
[Solved]-Routing error: No route matches [OPTIONS]-ruby
Coding example for the question Routing error: No route matches [OPTIONS]-ruby.
Read more >
Solved: Rails API error 'no route matches [options] 'users' even ...
As i struggled my way through rails API development, i came across this really frustrating error which got me wondering what the hell...
Read more >
RoutingError (No route matches "*" with {:method=>:options})
ActionController::RoutingError (No route matches "*" with ... The strange thing is this error isn't logged when I click a page--It appears ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found