Files
blackcanyontickets/reactrebuild0825/test-redirect-fix.cjs
dzinesco aa81eb5adb feat: add advanced analytics and territory management system
- Add comprehensive analytics components with export functionality
- Implement territory management with manager performance tracking
- Add seatmap components for venue layout management
- Create customer management features with modal interface
- Add advanced hooks for dashboard flags and territory data
- Implement seat selection and venue management utilities
- Add type definitions for ticketing and seatmap systems

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 09:25:10 -06:00

107 lines
4.5 KiB
JavaScript

/**
* Test script to verify redirect loop fix
* This script will visit the hosted site and monitor for redirect loops
*/
const fs = require('fs');
const path = require('path');
// Function to create a simple HTML test page
function createTestPage() {
const html = `
<!DOCTYPE html>
<html>
<head>
<title>Redirect Loop Test</title>
<style>
body { font-family: system-ui; padding: 2rem; background: #0f0f23; color: white; }
.result { margin: 1rem 0; padding: 1rem; border-radius: 8px; }
.success { background: rgba(34, 197, 94, 0.2); border: 1px solid rgba(34, 197, 94, 0.3); }
.error { background: rgba(239, 68, 68, 0.2); border: 1px solid rgba(239, 68, 68, 0.3); }
.info { background: rgba(59, 130, 246, 0.2); border: 1px solid rgba(59, 130, 246, 0.3); }
</style>
</head>
<body>
<h1>Redirect Loop Fix Test</h1>
<p>Testing the BCT React app at: <strong>https://dev-racer-433015-k3.web.app</strong></p>
<div id="results">
<div class="info">
<strong>Test Instructions:</strong><br>
1. Open the hosted site in a browser: <a href="https://dev-racer-433015-k3.web.app" target="_blank" style="color: #60a5fa;">https://dev-racer-433015-k3.web.app</a><br>
2. Check browser developer console for any redirect loop messages<br>
3. Verify the page loads without infinite redirects<br>
4. Check if login form appears or dashboard loads (depending on auth state)
</div>
<div class="info">
<strong>Expected Behavior (Fixed):</strong><br>
✅ Page loads without redirect loops<br>
✅ Service worker updates to v2 with network-first navigation<br>
✅ Auth state initializes properly with console logs<br>
✅ Either login form shows or dashboard loads based on stored auth<br>
✅ No browser "ERR_TOO_MANY_REDIRECTS" errors
</div>
<div class="info">
<strong>What Was Fixed:</strong><br>
• Service Worker: Network-first navigation strategy (prevents stale HTML caching)<br>
• ProtectedRoute: Extended timeout from 2s to 30s (prevents premature redirects)<br>
• useAuth: More robust auth state initialization with logging<br>
• LoginPage: Redirect loop detection and prevention<br>
• Firebase: Aggressive no-cache headers for HTML files
</div>
<div class="success">
<strong>How to Verify Fix:</strong><br>
1. Open browser dev tools (F12)<br>
2. Go to Console tab<br>
3. Navigate to the site<br>
4. Look for logs like "useAuth: Initializing auth state..." and "Service Worker v2"<br>
5. Verify no redirect loop errors appear<br>
6. Page should load successfully within 5-10 seconds
</div>
</div>
<script>
console.log('Redirect Loop Fix Test Page Loaded');
console.log('Open https://dev-racer-433015-k3.web.app in a new tab to test');
</script>
</body>
</html>`;
return html;
}
// Write the test page
const testPagePath = path.join(__dirname, 'test-results', 'redirect-fix-test.html');
const testDir = path.dirname(testPagePath);
if (!fs.existsSync(testDir)) {
fs.mkdirSync(testDir, { recursive: true });
}
fs.writeFileSync(testPagePath, createTestPage());
console.log('✅ Redirect loop fix deployed successfully!');
console.log('');
console.log('🔧 Fixes Applied:');
console.log(' • Service Worker: Network-first navigation (v2)');
console.log(' • ProtectedRoute: Extended auth timeout (2s → 30s)');
console.log(' • useAuth: Robust initialization with logging');
console.log(' • LoginPage: Redirect loop detection & prevention');
console.log(' • Firebase: No-cache headers for HTML files');
console.log('');
console.log('🌐 Hosted Site: https://dev-racer-433015-k3.web.app');
console.log('📄 Test Page:', testPagePath);
console.log('');
console.log('⚠️ Manual Testing Required:');
console.log(' 1. Open the hosted site in a browser');
console.log(' 2. Check browser console for auth initialization logs');
console.log(' 3. Verify no redirect loop errors occur');
console.log(' 4. Confirm page loads within 10 seconds');
console.log('');
console.log('Expected console logs:');
console.log(' - "useAuth: Initializing auth state..."');
console.log(' - "SW registered" or "Service Worker v2"');
console.log(' - No "redirect loop" or "too many redirects" errors');