You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Keycloak 12.0.1访问realm登录页报MediaType not set错误怎么解决?

Keycloak 12.0.1 访问realm登录页500错误问题

在*Keycloak(服务端版本12.0.1)*中尝试访问realm登录页时,触发了如下错误:

09:44:04,737 ERROR [org.keycloak.headers.DefaultSecurityHeadersProvider] (default task-1)  MediaType not set on path /auth/realms/<realm-name>/protocol/openid-connect/auth, with response status 500
09:44:04,738 ERROR [io.undertow.request] (default task-1) UT005023: Exception handling request to /auth/realms/<realm-name>/protocol/openid-connect/auth: java.lang.RuntimeException: java.lang.RuntimeException: org.jboss.resteasy.spi.UnhandledException: javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error

以下是点击Angular网页登录按钮生成的跳转URL:

https://auth.<project-name>.local:5001/auth/realms/<realm-name>/protocol/openid-connect/auth?response_type=code&client_id=<client-id>&state=MWl1SkQwNE1vaXZ1LXdLVGh6MWhvZGJiVldPVy40RTJwU2pVfmZ5ZzhsTmRZ&redirect_uri=http%3A%2F%2F<realm-name>%3A4288%2F&scope=openid%20profile%20email%20offline_access%20<clientId>&code_challenge=OPHLi0y4cM0BtILP12xVwUH8p_SiJZjZx1c_ehsFwB4&code_challenge_method=S256&nonce=MWl1SkQwNE1vaXZ1LXdLVGh6MWhvZGJiVldPVy40RTJwU2pVfmZ5ZzhsTmRZ
Angular项目相关配置

auth.service.ts

public configure() {
  authConfig.issuer = `${this.settingsService.getBaseAuthUrl()}auth/realms/${this._window.location.hostname.split('.')[0]}`;
  this.oauthService.configure(authConfig);
}

auth.config.ts

export const authConfig: AuthConfig = {
  // skipIssuerCheck: null,
  // 身份提供商URL
  // issuer: `${authUrl}auth/realms/master`,
  redirectUri: document.getElementsByTagName('base')[0].href as string,
  clientId: '<clientId>',
  scope: 'openid profile email offline_access <clientId>',
  requireHttps: true,
  showDebugInformation: true,
  responseType: 'code',
  disableAtHashCheck: false    
};
解决方案

在realm设置中将LoginTheme配置为keycloak即可解决该问题。


内容的提问来源于stack exchange,提问作者Edoardo Zanotti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 18:36:01