Rails Quickstart: no route matches [GET] "/auth/auth0"

Hi there,

I have been following the Rails quickstart guide, adding everything it asks to my Rails 5.2.2 app.

However, whenever I visit http://localhost:3000/auth/auth0 I get:

Started GET "/auth/auth0" for 127.0.0.1 at 2019-03-04 14:06:39 +0000

ActionController::RoutingError (No route matches [GET] "/auth/auth0"):

actionpack (5.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.2) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.2) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.2) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.2) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.2) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.6) lib/rack/method_override.rb:22:in `call'
rack (2.0.6) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.2) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
rack-cors (1.0.2) lib/rack/cors.rb:97:in `call'
webpacker (3.5.5) lib/webpacker/dev_server_proxy.rb:22:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (5.2.2) lib/rails/engine.rb:524:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'

I’m slightly baffled as I believe this route is something the omniauth gem should set up by default. I can’t find anyone reporting similar issues in this forum or on StackOverflow. Am I missing something obvious?

I’ve definitely bundle installed, I’ve restarted my server, I’ve stopped spring… still no luck.

routes.rb:

Rails.application.routes.draw do
   devise_for :users

   root to: "pages#landing"
   get '/home', to: "pages#home", as: :home
   resources :articles, only: [:index, :show]
   get '/tags/:tag', to: 'tags#show', as: :tag
   get '/users/:id', to: 'users#show', as: :user
   get '/cards/:id', to: 'cards#show', as: :card

   # Auth0
   get 'auth/oauth2/callback' => 'auth0#callback'
   get 'auth/failure' => 'auth0#failure'
   ...

/config/initializers/auth0.rb

Rails.application.config.middleware.use OmniAuth::Builder do
   provider(
     :auth0,
     ENV['AUTH0_CLIENT_KEY'],
     ENV['AUTH0_CLIENT_SECRET'],
     'almanac.auth0.com',
     callback_path: '/auth/oauth2/callback',
     authorize_params: {
       scope: 'openid profile'
     }
   )
   end

Gemfile

gem 'omniauth', '~> 1.6.1'
gem 'omniauth-auth0', '~> 2.0.0'

Any help would be really appreciated!

—Dan

I took all the time to write this out then fixed it 30 seconds after: the /auth namespace was being used by devise-token-auth. When I removed that, it worked fine!

1 Like

Stoked you were finally able to find it! Thanks for sharing that little bug!

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.