![](/img/trans.png)
[英]Spring Boot - Angular CORS issue while redirecting to Keycloak Login Page
[英]CORS Issue with Angular and Spring Boot REST API With Keycloak
我已經使用keycloak(jboss/keycloak:12.0.3)構建了 Spring Boot REST API(2.3.2.RELEASE)、Angular(v10)應用程序以進行身份驗證和授權。
Spring 引導應用程序已使用KeycloakWebSecurityConfigurerAdapter進行配置,Angular 前端使用"keycloak-angular": "^8.1.0","keycloak-js": "^12.0.2" ,
目前,我可以通過 keycloak login window 使用 Angular 前端成功登錄應用程序。 But there is a CORS error when trying to do a POST or GET request to Spring Boot REST API using HttpClient in Angular Project.
令牌正確綁定到請求。 這個令牌是有效的,因為我可以通過 Postman 使用相同的令牌調用這個API 。
我嘗試過的解決方案:
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http.cors().disable();
}
There was an error in my configuration for cors, so basically your keycloak setup should be done with spring security as follows, It will resolve any kind of CORS related issues with Spring boot and Keycloak.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.