This commit is contained in:
@@ -28,12 +28,12 @@ window.taxbaikAdminSession = {
|
||||
const body = JSON.stringify(payload);
|
||||
if (navigator.sendBeacon) {
|
||||
const blob = new Blob([body], { type: 'application/json' });
|
||||
if (navigator.sendBeacon('/taxbaik/api/client-logs', blob)) {
|
||||
if (navigator.sendBeacon(window.taxbaikAdminSession.getApiUrl('/client-logs'), blob)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fetch('/taxbaik/api/client-logs', {
|
||||
fetch(window.taxbaikAdminSession.getApiUrl('/client-logs'), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body,
|
||||
@@ -248,6 +248,39 @@ window.taxbaikAdminSession = {
|
||||
return window.innerWidth || document.documentElement.clientWidth || 0;
|
||||
},
|
||||
|
||||
getAppRootPath: function () {
|
||||
try {
|
||||
const base = new URL(document.baseURI);
|
||||
let pathname = base.pathname || '/';
|
||||
|
||||
if (pathname.endsWith('/admin/')) {
|
||||
pathname = pathname.slice(0, -'/admin/'.length) || '/';
|
||||
} else if (pathname.endsWith('/portal/')) {
|
||||
pathname = pathname.slice(0, -'/portal/'.length) || '/';
|
||||
} else if (pathname.endsWith('/admin')) {
|
||||
pathname = pathname.slice(0, -'/admin'.length) || '/';
|
||||
} else if (pathname.endsWith('/portal')) {
|
||||
pathname = pathname.slice(0, -'/portal'.length) || '/';
|
||||
}
|
||||
|
||||
return pathname.endsWith('/') ? pathname.slice(0, -1) : pathname;
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
getAdminUrl: function (path) {
|
||||
const rootPath = window.taxbaikAdminSession.getAppRootPath();
|
||||
const normalizedPath = String(path || '').startsWith('/') ? String(path || '') : `/${String(path || '')}`;
|
||||
return `${window.location.origin}${rootPath}/admin${normalizedPath}`;
|
||||
},
|
||||
|
||||
getApiUrl: function (path) {
|
||||
const rootPath = window.taxbaikAdminSession.getAppRootPath();
|
||||
const normalizedPath = String(path || '').startsWith('/') ? String(path || '') : `/${String(path || '')}`;
|
||||
return `${window.location.origin}${rootPath}/api${normalizedPath}`;
|
||||
},
|
||||
|
||||
clearAuthToken: function () {
|
||||
try {
|
||||
localStorage.removeItem('accessToken');
|
||||
@@ -410,7 +443,7 @@ window.taxbaikAdminSession = {
|
||||
}
|
||||
|
||||
window.taxbaikAdminSession.traceUiState('admin-login', 'submit started');
|
||||
const loginUrl = new URL('/taxbaik/api/auth/login', window.location.origin).toString();
|
||||
const loginUrl = window.taxbaikAdminSession.getApiUrl('/auth/login');
|
||||
const response = await fetch(loginUrl, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -455,7 +488,7 @@ window.taxbaikAdminSession = {
|
||||
// Blazor가 대시보드 페이지를 로드할 때 CustomAuthenticationStateProvider가
|
||||
// 자동으로 localStorage에서 토큰을 복원합니다
|
||||
setTimeout(() => {
|
||||
window.location.href = '/taxbaik/admin/dashboard';
|
||||
window.location.href = window.taxbaikAdminSession.getAdminUrl('/dashboard');
|
||||
}, 200);
|
||||
} catch (error) {
|
||||
window.taxbaikAdminSession.traceUiState('admin-login', `submit failed: ${error?.message || 'login failed'}`);
|
||||
|
||||
Reference in New Issue
Block a user