const AUTH_HOST = 'https://account.rokojori.com'; const APP_URL = 'https://roject.rokojori.com'; interface JwtUser { userId: string; email: string; roles: string[]; products: string[]; } class AppNav extends HTMLElement { async connectedCallback(): Promise { const res = await fetch( '/api/auth/me' ); if ( !res.ok ) { const loginHref = `${AUTH_HOST}/login.html?redirect=${encodeURIComponent( APP_URL )}`; this.innerHTML = ` `; return; } const user = await res.json() as JwtUser; const logoutHref = `${AUTH_HOST}/api/auth/logout?redirect=${encodeURIComponent( APP_URL )}`; this.innerHTML = ` `; } } customElements.define( 'app-nav', AppNav );