Round 19: Fix auth 500/session persistence, script tag warning, module factory error, rate limiting
- Fix auth session persistence: set cookie on both cookies() and NextResponse - Fix isSecureRequest: check x-forwarded-proto for HTTPS proxy support - Fix excessive GET /api/auth polling: add useRef guard to prevent duplicate checks - Increase rate limits: auth POST 30/min, auth GET 120/min - Fix script tag warning: use ref-based textContent instead of dangerouslySetInnerHTML in chart.tsx - Fix sanitizeHtml: improve regex patterns for script tag removal - Fix module factory error: disable SW registration in dev, skip /_next/ caching in sw.js - Bump SW cache version v2→v3 to force cache invalidation - Better error handling in auth route with specific error messages
This commit is contained in:
1 parent
760fa70e82
commit
74404708e5
9 files changed
+192
-47
No files matched your search
+6
-1
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect } from 'react';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { useAppStore } from '@/lib/store';
|
||||
import { fetchCurrentUser } from '@/lib/api';
|
||||
import AuthView from '@/components/auth-view';
|
||||
@@ -10,8 +10,13 @@ export default function Home() {
|
||||
const currentUser = useAppStore((s) => s.currentUser);
|
||||
const isLoadingAuth = useAppStore((s) => s.isLoadingAuth);
|
||||
const setCurrentUser = useAppStore((s) => s.setCurrentUser);
|
||||
const hasCheckedRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Prevent duplicate auth checks: only run once per component lifecycle
|
||||
if (hasCheckedRef.current) return;
|
||||
hasCheckedRef.current = true;
|
||||
|
||||
async function checkAuth() {
|
||||
try {
|
||||
const user = await fetchCurrentUser();
|
||||
|
||||
Reference in new issue
Block a user