Страница heroku.com не может быть найдена - app is rails api - PullRequest
0 голосов
/ 20 февраля 2020

У меня есть rails api с клиентом реакции. Мои рельсы API хорошо работает в местном масштабе. Когда я подтолкнул его к героку, он развернулся, но когда зашел посмотреть, он сказал, что моя страница не найдена. я добавил root маршрут, который он просил (?), но безрезультатно ... любая помощь будет оценена! я также проверил heroku, развернув тестовые приложения. Если они были сделаны с помощью --api, страницу снова найти не удалось. Я сделал один без --api, изначально он работал, но при попытке перенести db это привело к ошибкам отладки # 4 ...

                               Prefix Verb   URI Pattern                                                                              Controller#Action
                         api_v1_users GET    /api/v1/users(.:format)                                                                  api/v1/users#index
                                      POST   /api/v1/users(.:format)                                                                  api/v1/users#create
                          api_v1_user GET    /api/v1/users/:id(.:format)                                                              api/v1/users#show
                                      PATCH  /api/v1/users/:id(.:format)                                                              api/v1/users#update
                                      PUT    /api/v1/users/:id(.:format)                                                              api/v1/users#update
                                      DELETE /api/v1/users/:id(.:format)                                                              api/v1/users#destroy
                          api_v1_pets GET    /api/v1/pets(.:format)                                                                   api/v1/pets#index
                                      POST   /api/v1/pets(.:format)                                                                   api/v1/pets#create
                           api_v1_pet GET    /api/v1/pets/:id(.:format)                                                               api/v1/pets#show
                                      PATCH  /api/v1/pets/:id(.:format)                                                               api/v1/pets#update
                                      PUT    /api/v1/pets/:id(.:format)                                                               api/v1/pets#update
                                      DELETE /api/v1/pets/:id(.:format)                                                               api/v1/pets#destroy
                               api_v1 PATCH  /api/v1/pets/:id/toggle_adopt(.:format)                                                  api/v1/pets#toggle_adopt
                                      POST   /api/v1/pets/:id/adopt(.:format)                                                         api/v1/pets#adopt
                                      POST   /api/v1/users/:id/get_pet(.:format)                                                      api/v1/users#get_pet
                                      GET    /api/v1(.:format)                                                                        api/v1/pets#index
                         api_v1_login POST   /api/v1/login(.:format)                                                                  api/v1/auth#login
                    api_v1_auto_login GET    /api/v1/auto_login(.:format)                                                             api/v1/auth#auto_login
        rails_mandrill_inbound_emails POST   /rails/action_mailbox/mandrill/inbound_emails(.:format)                                  action_mailbox/ingresses/mandrill/inbound_emails#create
        rails_postmark_inbound_emails POST   /rails/action_mailbox/postmark/inbound_emails(.:format)                                  action_mailbox/ingresses/postmark/inbound_emails#create
           rails_relay_inbound_emails POST   /rails/action_mailbox/relay/inbound_emails(.:format)                                     action_mailbox/ingresses/relay/inbound_emails#create
        rails_sendgrid_inbound_emails POST   /rails/action_mailbox/sendgrid/inbound_emails(.:format)                                  action_mailbox/ingresses/sendgrid/inbound_emails#create
         rails_mailgun_inbound_emails POST   /rails/action_mailbox/mailgun/inbound_emails/mime(.:format)                              action_mailbox/ingresses/mailgun/inbound_emails#create
       rails_conductor_inbound_emails GET    /rails/conductor/action_mailbox/inbound_emails(.:format)                                 rails/conductor/action_mailbox/inbound_emails#index
                                      POST   /rails/conductor/action_mailbox/inbound_emails(.:format)                                 rails/conductor/action_mailbox/inbound_emails#create
        rails_conductor_inbound_email GET    /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                             rails/conductor/action_mailbox/inbound_emails#show
                                      PATCH  /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                             rails/conductor/action_mailbox/inbound_emails#update
                                      PUT    /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                             rails/conductor/action_mailbox/inbound_emails#update
                                      DELETE /rails/conductor/action_mailbox/inbound_emails/:id(.:format)                             rails/conductor/action_mailbox/inbound_emails#destroy
rails_conductor_inbound_email_reroute POST   /rails/conductor/action_mailbox/:inbound_email_id/reroute(.:format)                      rails/conductor/action_mailbox/reroutes#create
                   rails_service_blob GET    /rails/active_storage/blobs/:signed_id/*filename(.:format)                               active_storage/blobs#show
            rails_blob_representation GET    /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
                   rails_disk_service GET    /rails/active_storage/disk/:encoded_key/*filename(.:format)                              active_storage/disk#show
            update_rails_disk_service PUT    /rails/active_storage/disk/:encoded_token(.:format)                                      active_storage/disk#update
                 rails_direct_uploads POST   /rails/active_storage/direct_uploads(.:format)                                           active_storage/direct_uploads#create
// ♥ heroku logs
2020-02-19T16:44:53.897044+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] actionpack (6.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
2020-02-19T16:44:53.897044+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] railties (6.0.2.1) lib/rails/rack/logger.rb:38:in `call_app'
2020-02-19T16:44:53.897044+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `block in call'
2020-02-19T16:44:53.897044+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
2020-02-19T16:44:53.897045+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
2020-02-19T16:44:53.897045+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `tagged'
2020-02-19T16:44:53.897045+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `call'
2020-02-19T16:44:53.897046+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] actionpack (6.0.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
2020-02-19T16:44:53.897046+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
2020-02-19T16:44:53.897046+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] rack (2.2.2) lib/rack/runtime.rb:22:in `call'
2020-02-19T16:44:53.897047+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] activesupport (6.0.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
2020-02-19T16:44:53.897047+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
2020-02-19T16:44:53.897047+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] actionpack (6.0.2.1) lib/action_dispatch/middleware/static.rb:126:in `call'
2020-02-19T16:44:53.897047+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] rack (2.2.2) lib/rack/sendfile.rb:110:in `call'
2020-02-19T16:44:53.897047+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] actionpack (6.0.2.1) lib/action_dispatch/middleware/host_authorization.rb:77:in `call'
2020-02-19T16:44:53.897048+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] rack-cors (1.1.1) lib/rack/cors.rb:100:in `call'
2020-02-19T16:44:53.897048+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] railties (6.0.2.1) lib/rails/engine.rb:526:in `call'
2020-02-19T16:44:53.897048+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] puma (4.3.1) lib/puma/configuration.rb:228:in `call'
2020-02-19T16:44:53.897048+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] puma (4.3.1) lib/puma/server.rb:681:in `handle_request'
2020-02-19T16:44:53.897049+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] puma (4.3.1) lib/puma/server.rb:472:in `process_client'
2020-02-19T16:44:53.897049+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] puma (4.3.1) lib/puma/server.rb:328:in `block in run'
2020-02-19T16:44:53.897049+00:00 app[web.1]: [0e32db7c-e3cb-4afb-a003-d73b769ce813] puma (4.3.1) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
2020-02-19T17:22:24.570026+00:00 heroku[web.1]: Idling
2020-02-19T17:22:24.573775+00:00 heroku[web.1]: State changed from up to down
2020-02-19T17:22:25.738188+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-02-19T17:22:25.771134+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2020-02-19T17:22:25.773522+00:00 app[web.1]: === puma shutdown: 2020-02-19 17:22:25 +0000 ===
2020-02-19T17:22:25.773546+00:00 app[web.1]: - Goodbye!
2020-02-19T17:22:25.866786+00:00 heroku[web.1]: Process exited with status 143
2020-02-19T18:47:00.519301+00:00 heroku[web.1]: Unidling
2020-02-19T18:47:00.536382+00:00 heroku[web.1]: State changed from down to starting
2020-02-19T18:47:03.058431+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}`
2020-02-19T18:47:05.399248+00:00 app[web.1]: Puma starting in single mode...
2020-02-19T18:47:05.399262+00:00 app[web.1]: * Version 4.3.1 (ruby 2.6.5-p114), codename: Mysterious Traveller
2020-02-19T18:47:05.399263+00:00 app[web.1]: * Min threads: 5, max threads: 5
2020-02-19T18:47:05.399263+00:00 app[web.1]: * Environment: production
2020-02-19T18:47:11.357442+00:00 app[web.1]: * Listening on tcp://0.0.0.0:54444
2020-02-19T18:47:11.357812+00:00 app[web.1]: Use Ctrl-C to stop
2020-02-19T18:47:11.926899+00:00 heroku[web.1]: State changed from starting to up
2020-02-19T18:47:12.591966+00:00 heroku[router]: at=info method=OPTIONS path="/api/v1/auto_login" host=boiling-garden-61294.herokuapp.com request_id=63546cfe-0db6-4273-88ff-652097e7432c fwd="184.153.22.244" dyno=web.1 connect=1ms service=1ms status=200 bytes=307 protocol=https
2020-02-19T19:02:50.855756+00:00 app[web.1]: I, [2020-02-19T19:02:50.855651 #4]  INFO -- : [3c337a3b-162b-4362-8d16-0ed2f50318c5] Started GET "/api/v1/auto_login" for 184.153.22.244 at 2020-02-19 19:02:50 +0000
2020-02-19T19:02:50.857404+00:00 app[web.1]: I, [2020-02-19T19:02:50.857329 #4]  INFO -- : [3c337a3b-162b-4362-8d16-0ed2f50318c5] Processing by Api::V1::AuthController#auto_login as */*
2020-02-19T19:02:52.341221+00:00 app[web.1]: D, [2020-02-19T19:02:52.341059 #4] DEBUG -- : [3c337a3b-162b-4362-8d16-0ed2f50318c5]   User Load (17.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 4], ["LIMIT", 1]]
2020-02-19T19:02:52.426916+00:00 app[web.1]: D, [2020-02-19T19:02:52.426791 #4] DEBUG -- : [3c337a3b-162b-4362-8d16-0ed2f50318c5]   CACHE User Load (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 4], ["LIMIT", 1]]
2020-02-19T19:02:52.473014+00:00 app[web.1]: D, [2020-02-19T19:02:52.472882 #4] DEBUG -- : [3c337a3b-162b-4362-8d16-0ed2f50318c5] [active_model_serializers]   Pet Load (35.6ms)  SELECT "pets".* FROM "pets" WHERE "pets"."owner_id" = $1  [["owner_id", 4]]
2020-02-19T19:02:52.493448+00:00 app[web.1]: I, [2020-02-19T19:02:52.493334 #4]  INFO -- : [3c337a3b-162b-4362-8d16-0ed2f50318c5] [active_model_serializers] Rendered UserSerializer with ActiveModelSerializers::Adapter::Attributes (65.55ms)
2020-02-19T19:02:52.493828+00:00 app[web.1]: I, [2020-02-19T19:02:52.493752 #4]  INFO -- : [3c337a3b-162b-4362-8d16-0ed2f50318c5] Completed 200 OK in 1636ms (Views: 23.2ms | ActiveRecord: 1558.9ms | Allocations: 17956)
2020-02-19T19:02:52.495894+00:00 heroku[router]: at=info method=GET path="/api/v1/auto_login" host=boiling-garden-61294.herokuapp.com request_id=3c337a3b-162b-4362-8d16-0ed2f50318c5 fwd="184.153.22.244" dyno=web.1 connect=0ms service=1641ms status=304 bytes=636 protocol=https
2020-02-19T19:38:32.700667+00:00 heroku[web.1]: Idling
2020-02-19T19:38:32.705096+00:00 heroku[web.1]: State changed from up to down
2020-02-19T19:38:33.831696+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-02-19T19:38:33.852410+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2020-02-19T19:38:33.858074+00:00 app[web.1]: === puma shutdown: 2020-02-19 19:38:33 +0000 ===
2020-02-19T19:38:33.858355+00:00 app[web.1]: - Goodbye!
2020-02-19T19:38:33.969920+00:00 heroku[web.1]: Process exited with status 143
2020-02-19T20:07:07.613633+00:00 heroku[web.1]: Unidling
2020-02-19T20:07:07.628601+00:00 heroku[web.1]: State changed from down to starting
2020-02-19T20:07:10.629524+00:00 heroku[web.1]: Starting process with command `bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}`
2020-02-19T20:07:13.443149+00:00 app[web.1]: Puma starting in single mode...
2020-02-19T20:07:13.443242+00:00 app[web.1]: * Version 4.3.1 (ruby 2.6.5-p114), codename: Mysterious Traveller
2020-02-19T20:07:13.443243+00:00 app[web.1]: * Min threads: 5, max threads: 5
2020-02-19T20:07:13.443244+00:00 app[web.1]: * Environment: production
2020-02-19T20:07:19.064575+00:00 app[web.1]: * Listening on tcp://0.0.0.0:26954
2020-02-19T20:07:19.065126+00:00 app[web.1]: Use Ctrl-C to stop
2020-02-19T20:07:19.389039+00:00 heroku[web.1]: State changed from starting to up
2020-02-19T20:07:21.691904+00:00 app[web.1]: I, [2020-02-19T20:07:21.691780 #4]  INFO -- : [de344029-a862-437f-8eeb-e7c3092c3894] Started GET "/" for 184.153.22.244 at 2020-02-19 20:07:21 +0000
2020-02-19T20:07:21.693363+00:00 app[web.1]: F, [2020-02-19T20:07:21.693281 #4] FATAL -- : [de344029-a862-437f-8eeb-e7c3092c3894]
2020-02-19T20:07:21.693364+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] ActionController::RoutingError (No route matches [GET] "/"):
2020-02-19T20:07:21.693365+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894]
2020-02-19T20:07:21.693379+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] actionpack (6.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:36:in `call'
2020-02-19T20:07:21.693379+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] actionpack (6.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
2020-02-19T20:07:21.693380+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] railties (6.0.2.1) lib/rails/rack/logger.rb:38:in `call_app'
2020-02-19T20:07:21.693380+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `block in call'
2020-02-19T20:07:21.693381+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
2020-02-19T20:07:21.693381+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
2020-02-19T20:07:21.693381+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `tagged'
2020-02-19T20:07:21.693382+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `call'
2020-02-19T20:07:21.693382+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] actionpack (6.0.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
2020-02-19T20:07:21.693382+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
2020-02-19T20:07:21.693383+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] rack (2.2.2) lib/rack/runtime.rb:22:in `call'
2020-02-19T20:07:21.693384+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] activesupport (6.0.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
2020-02-19T20:07:21.693385+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
2020-02-19T20:07:21.693385+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] actionpack (6.0.2.1) lib/action_dispatch/middleware/static.rb:126:in `call'
2020-02-19T20:07:21.693385+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] rack (2.2.2) lib/rack/sendfile.rb:110:in `call'
2020-02-19T20:07:21.693386+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] actionpack (6.0.2.1) lib/action_dispatch/middleware/host_authorization.rb:77:in `call'
2020-02-19T20:07:21.693386+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] rack-cors (1.1.1) lib/rack/cors.rb:100:in `call'
2020-02-19T20:07:21.693387+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] railties (6.0.2.1) lib/rails/engine.rb:526:in `call'
2020-02-19T20:07:21.693387+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] puma (4.3.1) lib/puma/configuration.rb:228:in `call'
2020-02-19T20:07:21.693387+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] puma (4.3.1) lib/puma/server.rb:681:in `handle_request'
2020-02-19T20:07:21.693388+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] puma (4.3.1) lib/puma/server.rb:472:in `process_client'
2020-02-19T20:07:21.693388+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] puma (4.3.1) lib/puma/server.rb:328:in `block in run'
2020-02-19T20:07:21.693389+00:00 app[web.1]: [de344029-a862-437f-8eeb-e7c3092c3894] puma (4.3.1) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
2020-02-19T20:07:21.695902+00:00 heroku[router]: at=info method=GET path="/" host=boiling-garden-61294.herokuapp.com request_id=de344029-a862-437f-8eeb-e7c3092c3894 fwd="184.153.22.244" dyno=web.1 connect=1ms service=7ms status=404 bytes=191 protocol=https
2020-02-19T20:38:22.500446+00:00 heroku[web.1]: Idling
2020-02-19T20:38:22.505029+00:00 heroku[web.1]: State changed from up to down
2020-02-19T20:38:23.149591+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2020-02-19T20:38:23.150452+00:00 app[web.1]: === puma shutdown: 2020-02-19 20:38:23 +0000 ===
2020-02-19T20:38:23.150454+00:00 app[web.1]: - Goodbye!
2020-02-19T20:38:23.141795+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-02-19T20:38:23.197413+00:00 heroku[web.1]: Process exited with status 143```

1 Ответ

0 голосов
/ 20 февраля 2020

Это нормальное поведение только в --api приложениях, просто рельсы не знают, что обслуживать. В API только приложения ApplicationController наследуются от ActionController::API вместо ActionController::Base, что устраняет некоторые функции, требуемые браузерами.

Контроллер API отличается от обычного контроллера в том смысле, что по умолчанию он не включает некоторые функции, которые обычно требуются только для доступа через браузер: макеты и рендеринг шаблонов, fla sh, ресурсы и т. д. Это делает весь стек контроллера более тонким, подходящим для приложений API. Это не означает, что у вас не будет таких функций, если они вам понадобятся: все они доступны для включения в ваше приложение, они просто не являются частью стека контроллера API по умолчанию.

Источник: https://api.rubyonrails.org/classes/ActionController/API.html

Если вы разработали приложение как json API, все URL-адреса формата json должны работать нормально.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...