目前,我正在尝试使用Firebase作为后端设置NextJS应用程序。因为firebase无法处理完整搜索,所以我想使用typesensens。他们提供了一个非常好的文档,如何进行设置:
对于Typesene,我已经为我所有3个环境设置了Docker容器(Docker typesensens 提供)。要从Docker请求信息,我使用 typesensensensensearch-Adapter
-NPM软件包。在应用程序中,我具有不同的用户角色,因此并非每个人都能看到所有索引数据 - 因此,我使用范围搜索的搜索,该搜索可以通过用户登录时生成的apikey可以通过( scoped api key )。因此,Apikey根据用户和用户角色而变化。我当前的设置运行良好,并且搜索已经在工作。
我唯一的问题是,我无法捕获< instantsearch>
-component正在投掷错误。例如,如果Docker离线或生成的Apikey无效。
我尝试了多个解决方案,但找不到适当的解决方案:
i找到了一个具有类似设置的代码和框。沙箱使用Algolia而不是类型义,但是弹出的错误是相同的: https://codesandbox.io/s/fib6jm?file=/app.tsx:1043-1056
- 访问app.tsx
- 行38
- 删除字符串
未熟悉,未指定的“错误”事件。 ([[对象对象])< / code>弹出了
如何捕获 /访问此错误以重新路由或显示错误屏幕?
Currently I'm trying to setup a nextjs app with firebase as backend. Because firebase cant handle a fulltext search, I want to use typesense. They provide a really nice documentation how to set it up: https://typesense.org/docs/guide/firebase-full-text-search.html
For typesene I already set up docker containers for all my 3 environment (the docker typesense provides). To request information back from the docker I use the typesense-instantsearch-adapter
- npm Package. In the app I have different user roles, so not everyone can see all indexed data - therefore I use a scoped search which is possible through the apiKey I generate when the users logs in (scoped api key). The apiKey therefore is variable depending on the user and the user role. My current setup works fine and also the search is already working.
The only problem I have is, that I cannot catch the errors the <InstantSearch>
-Component is throwing. For example if the docker is offline or if the generated apiKey is not valid.
I tried multiple solutions, but could not find a proper solution:
- Error boundary around the component (react docu)
- Error boundary npm package
- Try/catch block around the component
I found a codesandbox that has a quit similar setup. The sandbox is using algolia instead of typesense, but the error that pops up is the same: https://codesandbox.io/s/fib6jm?file=/App.tsx:1043-1056
- Go to App.tsx
- line 38
- remove string
Uncaught, unspecified "error" event. ([object Object])
pops up
How can I catch / access this error to reroute or show an error screen?
发布评论