![](/img/trans.png)
[英]Spring Boot with Webflux: No 'Access-Control-Allow-Origin' header is present on the requested resource
[英]Spring Boot + React + Keycloak after login returns No Access-Controll-Allow-Origin header is present
我正在尝试向我的 SpringBoot 应用程序添加前端。 我也有一个完美连接的用户提供商,因为如果我做了一个 CURL 它就可以工作。
The problem begins when connecting react to Keycloak to do a login, it shows the login page, but when the login is OK it returns
Access to XMLHttpRequest at 'http://localhost:18080/auth/realms/Realm/protocol/openid-connect/token' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
它仍然是 Keycloak 的问题,因为它由 CURL 工作,但我无法很好地配置它。
我还在客户端的 Web 起源中添加了一个 *。
您不会使用curl
重现CORS问题,因为它是浏览器约定。
基本上,当客户端请求包含以下内容时,浏览器会将请求视为 CORS:
headers:
Origin: 127.0.0.1
Set-Fetch-Mode: cors
并且服务器响应必须包含: Access-Control-Allow-Origin: *
其中 * 可以针对特定资源进行更改。
请参阅 Spring 中有关 CORS 和@CrossOrigin
注释的文章
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.