【发布时间】:2023-03-29 22:26:01
【问题描述】:
我正在 localhost:3000 上开发一个 REACT 应用程序,并在 localhost:8080 上运行一个 Spring Data Rest 后端。我发现了如何禁用特定 RestRepositories 的 CORS 策略,例如:
@CrossOrigin("*")
public interface EmployeeRepository extends PagingAndSortingRepository<Employee, Long> {
}
现在可以访问以下 URL:localhost:8080/api/employees
但是,我正在尝试对基本路径 url 本身执行 GET 请求:localhost:8080/api。这仍然被 CORS 策略阻止。我想禁用该 URL 上的 CORS 策略。
我找到了以下文档:https://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.configuring-cors 这适用于存储库本身,但在基本 URL 上没有结果。
非常感谢任何想法。
【问题讨论】:
标签: cors spring-data-rest base-path