[英]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.