Skip to content

Commit efb44d7

Browse files
committed
fix: logout host
1 parent f5108f6 commit efb44d7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

frontend/src/pages/Layout/Header.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,20 @@ export function Header() {
8989

9090
const handleLogout = () => {
9191
if (authMode === 'SSO') {
92-
// SSO 模式:跳转到 OMS 登出
93-
window.location.href = `${OMS_LOGOUT_URL}?redirect=${encodeURIComponent(window.location.href)}`;
92+
// SSO 模式:检查是否配置了有效的登出 URL
93+
const logoutUrl = OMS_LOGOUT_URL;
94+
95+
// 如果配置的是默认值(内部 service 名称),只清除本地状态
96+
if (logoutUrl.includes('oms-service') || logoutUrl.includes('localhost')) {
97+
console.warn('OMS logout URL not configured or using internal address, skipping redirect');
98+
setCurrentUser(null);
99+
setAuthMode('NONE');
100+
message.success(t('user.messages.logoutSuccess'));
101+
window.location.reload();
102+
} else {
103+
// 使用配置的登出 URL
104+
window.location.href = `${logoutUrl}?redirect=${encodeURIComponent(window.location.href)}`;
105+
}
94106
} else {
95107
// JWT 模式:清除本地 session
96108
localStorage.removeItem('session');

0 commit comments

Comments
 (0)