Skip to content

Commit d9a7288

Browse files
committed
fix(events): no profile request on public event pages when signed out
1 parent 79fe774 commit d9a7288

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/app/(app)/(events)/events/[id]/event-detail-client.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { EmptyState } from "@/components/ui/empty-state";
3535
import { Skeleton } from "@/components/ui/skeleton";
3636
import { CountdownSticker, LoopPointsSticker } from "@/components/ui/stickers";
3737
import { useProfile } from "@/hooks/use-profile";
38+
import { hasAuthCookie } from "@/lib/auth-cookie";
3839
import { fetcher } from "@/lib/api";
3940
import { type CalendarEvent, downloadAppleCalendarIcs, openGoogleCalendar } from "@/lib/calendar";
4041
import { haptics } from "@/lib/haptics";
@@ -64,7 +65,10 @@ function DetailSkeleton() {
6465

6566
export function EventDetailClient({ eventId, initialEvent, initialRelated }: EventDetailClientProps) {
6667
const router = useRouter();
67-
const { profile } = useProfile();
68+
// Public page: only ask for the profile when a session cookie exists (no 401 for signed-out visitors).
69+
const [hasSession, setHasSession] = useState(false);
70+
useEffect(() => setHasSession(hasAuthCookie()), []);
71+
const { profile } = useProfile({ enabled: hasSession });
6872
const swrKey = `/api/events/${eventId}`;
6973
const { data, isLoading, error } = useSWR<{ event: any }>(swrKey, fetcher, {
7074
fallbackData: initialEvent ? { event: initialEvent } : undefined,

0 commit comments

Comments
 (0)