简体   繁体   English

ActionController :: RoutingError:没有路由与[GET]“ /”匹配

[英]ActionController::RoutingError: No route matches [GET] “/”

I have a Rails API which is being accessed by my React client-side. 我有一个由我的React客户端访问的Rails API Every time the react application is loaded it makes a get request to the API for the path / and this raises the error: 每次加载React应用程序时,它都会向API请求路径/get请求,这会引发错误:

ActionController::RoutingError: No route matches [GET] "/"

Although this doesn't really affect user interaction on the application but I would still like to remove this. 尽管这并没有真正影响应用程序上的用户交互,但是我仍然希望删除它。

My API has a normal path of <url>/backend-api/v2.3.3/.. 我的API的常规路径为<url>/backend-api/v2.3.3/..

I think this can be fixed by adding a root path on the routes but considering that the initially loaded pages on React are static and don't really need to make an API call, how can I catch this initial GET / and prevent the error from being raised? 我认为可以通过在路由上添加root路径来解决此问题,但考虑到React上最初加载的页面是静态的,并且实际上不需要进行API调用,我如何捕获此初始GET /并防止出现错误长大了吗?

将其添加到api作用域下:

get '/', to: proc { [200, {}, ['']] }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ActionController :: RoutingError(没有路由与[GET]匹配 - ActionController::RoutingError (No route matches [GET] " 没有路由匹配[GET]“ /”(ActionController :: RoutingError) - No route matches [GET] “/” (ActionController::RoutingError) ActionController :: RoutingError-没有路由匹配 - ActionController::RoutingError - No route matches ActionController :: RoutingError(没有路由匹配 - ActionController::RoutingError (No route matches CRUD ActionController :: RoutingError(没有路由与[GET]匹配 - CRUD ActionController::RoutingError (No route matches [GET] ActionController :: RoutingError(没有路由与[GET]“ / users”匹配): - ActionController::RoutingError (No route matches [GET] “/users”): 设计 - ActionController :: RoutingError(没有路由匹配[GET]“/ confirm”): - Devise - ActionController::RoutingError (No route matches [GET] “/confirm”): ActionController :: RoutingError没有与“ / cloudfoundryapplication”匹配的[GET]和[OPTION]路由 - ActionController::RoutingError No route matches [GET] & [OPTION] for “/cloudfoundryapplication” ActionController :: RoutingError(没有路由与[GET]“ / assets / images匹配 - ActionController::RoutingError (No route matches [GET] "/assets/images 回形针ActionController :: RoutingError:没有路线与[GET]匹配 - Paperclip ActionController::RoutingError: No route matches [GET]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM