部署到Heroku的React路由问题

时间:2018-03-31 03:24:38

标签: ruby-on-rails reactjs routing

我有一个使用Rails API作为后端的React应用程序。一切都在开发中运作良好。但是,一旦部署到Heroku,我的路由就会在手动刷新时失败。唯一有效的路线是Home路线。你可以在这里找到应用.... http://card-collector-app.herokuapp.com/

登录后,您将进入卡片查看页面。但是,如果你进行手动刷新,一切都会变成空白。手动路由回到主页有效,但这是唯一可行的。

如果有人有什么想法,我会很乐意帮助吗?

这是heroku日志。如您所见,首先它找到路线。但是在手动刷新时,它会抛出状态为404的路由错误,其中包含大量其他致命错误。

2018-04-01T15:38:57.187873+00:00 heroku[router]: at=info method=GET path="/1/cards" host=card-collector-app.herokuapp.com request_id=6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c fwd="98.195.93.19" dyno=web.1 connect=1ms service=6ms status=404 bytes=191 protocol=http
2018-04-01T15:38:57.183795+00:00 app[web.1]: I, [2018-04-01T15:38:57.183477 #4]  INFO -- : [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] Started GET "/1/cards" for 98.195.93.19 at 2018-04-01 15:38:57 +0000
2018-04-01T15:38:57.185195+00:00 app[web.1]: F, [2018-04-01T15:38:57.185127 #4] FATAL -- : [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c]   
2018-04-01T15:38:57.185519+00:00 app[web.1]: F, [2018-04-01T15:38:57.185227 #4] FATAL -- : [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] ActionController::RoutingError (No route matches [GET] "/1/cards"):
2018-04-01T15:38:57.185652+00:00 app[web.1]: F, [2018-04-01T15:38:57.185545 #4] FATAL -- : [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c]   
2018-04-01T15:38:57.185783+00:00 app[web.1]: F, [2018-04-01T15:38:57.185697 #4] FATAL -- : [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
2018-04-01T15:38:57.185786+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
2018-04-01T15:38:57.185788+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:36:in `call_app'
2018-04-01T15:38:57.185790+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:24:in `block in call'
2018-04-01T15:38:57.185792+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/tagged_logging.rb:69:in `block in tagged'
2018-04-01T15:38:57.185794+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/tagged_logging.rb:26:in `tagged'
2018-04-01T15:38:57.185795+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/tagged_logging.rb:69:in `tagged'
2018-04-01T15:38:57.185797+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/rack/logger.rb:24:in `call'
2018-04-01T15:38:57.185799+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
2018-04-01T15:38:57.185801+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/request_id.rb:25:in `call'
2018-04-01T15:38:57.185804+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
2018-04-01T15:38:57.185802+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/rack-2.0.4/lib/rack/runtime.rb:22:in `call'
2018-04-01T15:38:57.185806+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/executor.rb:12:in `call'
2018-04-01T15:38:57.185807+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/actionpack-5.1.6/lib/action_dispatch/middleware/static.rb:125:in `call'
2018-04-01T15:38:57.185809+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/rack-2.0.4/lib/rack/sendfile.rb:111:in `call'
2018-04-01T15:38:57.185811+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/rack-cors-1.0.2/lib/rack/cors.rb:97:in `call'
2018-04-01T15:38:57.185812+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/engine.rb:522:in `call'
2018-04-01T15:38:57.185814+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/puma-3.11.3/lib/puma/configuration.rb:225:in `call'
2018-04-01T15:38:57.185816+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/puma-3.11.3/lib/puma/server.rb:624:in `handle_request'
2018-04-01T15:38:57.185817+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/puma-3.11.3/lib/puma/server.rb:438:in `process_client'
2018-04-01T15:38:57.185819+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/puma-3.11.3/lib/puma/server.rb:302:in `block in run'
2018-04-01T15:38:57.185820+00:00 app[web.1]: [6d8a3f8f-2b2a-4ecd-98ad-1216c2eccd9c] vendor/bundle/ruby/2.5.0/gems/puma-3.11.3/lib/puma/thread_pool.rb:120:in `block in spawn_thread'

0 个答案:

没有答案