如何从 React 客户端访问 JHipster 实体?

How to get access to JHipster entities from the React client?

我想在可通过 localhost:8080/public/

访问的页面上列出名为 google 的特定实体的每条记录

我已经将 /entities/google-results/google-result.tsx 中的 tsx 文件复制到 /modules/public/home.tsx 中,我创建了一个新路由并将其绑定到该组件。

它编译成功但是当我点击 localhost/public 时,javascript 控制台显示:

Failed to load resource: the server responded with a status of 401 (Unauthorized)

解决这个问题的最佳方法是什么?

在SecurityConfiguration.java中:

.antMatchers("/api/**").hasAnyRole("ANONYMOUS","ADMIN", "USER")
.antMatchers("/public/**").hasAnyRole("ANONYMOUS","ADMIN", "USER")

显然不建议让它那样做,但可以了解它是如何工作的。