diff --git a/frontend/src/components/blog/comments/Comments.tsx b/frontend/src/components/blog/comments/Comments.tsx index 6173b9d..21836ad 100644 --- a/frontend/src/components/blog/comments/Comments.tsx +++ b/frontend/src/components/blog/comments/Comments.tsx @@ -14,10 +14,7 @@ interface CommentsProps { } export default function Comments(props: CommentsProps) { - const isAuthFromSSR = props.isAuthorized ?? false; - console.log("[Comments] SSR isAuthorized:", isAuthFromSSR); - const [isAuthenticated, setIsAuthenticated] = createSignal(isAuthFromSSR); - console.log("[Comments] Initial isAuthenticated:", isAuthenticated()); + const [isAuthenticated, setIsAuthenticated] = createSignal(props.isAuthorized ?? false); const [currentUser, setCurrentUser] = createSignal<{ id: string; name: string; @@ -302,11 +299,6 @@ export default function Comments(props: CommentsProps) { )} - {/* DEBUG SSR */} -
- SSR isAuthorized: {String(props.isAuthorized)} | client isAuthenticated: {String(isAuthenticated())} -
- {isLoading() ? (
diff --git a/frontend/src/lib/pb.ts b/frontend/src/lib/pb.ts index d898212..8f364bc 100644 --- a/frontend/src/lib/pb.ts +++ b/frontend/src/lib/pb.ts @@ -5,25 +5,6 @@ const PB_URL = import.meta.env.PB_POCKETBASE_URL || 'http://127.0.0.1:8090'; export const pb = new PocketBase(PB_URL); -if (typeof window !== 'undefined') { - const token = localStorage.getItem('auth_token'); - const userStr = localStorage.getItem('user'); - - // Инициализируем куку из localStorage если её нет - if (token && !document.cookie.includes('pb_auth')) { - document.cookie = `pb_auth=${token}; path=/; max-age=${7 * 24 * 60 * 60}; SameSite=Lax`; - } - - if (token && userStr) { - try { - const user = JSON.parse(userStr); - pb.authStore.save(token, user); - } catch (e) { - console.error('Failed to restore auth:', e); - } - } -} - export interface PostVotes { id: string; post_id: string; diff --git a/frontend/src/pages/blog/[slug].astro b/frontend/src/pages/blog/[slug].astro index 5693f60..1774a3c 100644 --- a/frontend/src/pages/blog/[slug].astro +++ b/frontend/src/pages/blog/[slug].astro @@ -33,8 +33,6 @@ if (pbAuthCookie && PB_POCKETBASE_URL && PB_POCKETBASE_URL.startsWith('http')) { const controller = new AbortController(); const timeoutId = setTimeout(() => controller.abort(), 5000); - console.log('[SSR] Checking auth with PB...'); - const response = await fetch(`${PB_POCKETBASE_URL}/api/collections/users/auth-refresh`, { method: 'POST', headers: { @@ -45,20 +43,15 @@ if (pbAuthCookie && PB_POCKETBASE_URL && PB_POCKETBASE_URL.startsWith('http')) { }); clearTimeout(timeoutId); - console.log('[SSR] Auth response:', response.status); if (response.ok) { isAuthorized = true; - console.log('[SSR] User authorized'); } else { Astro.cookies.delete('pb_auth', { path: '/' }); - console.log('[SSR] Auth failed, cookie deleted'); } } catch (e) { console.error('[SSR Auth] Error:', e); } -} else { - console.log('[SSR] No cookie or no PB_URL'); } const { likes = 0, dislikes = 0 } = await getPostVotesStats(post.id).catch(() => ({ likes: 0, dislikes: 0 }));