This commit is contained in:
Jeff Emmett 2025-06-21 19:23:44 +02:00
parent 091067f922
commit 0ccdd7e2b4
3 changed files with 17 additions and 54 deletions

8
pages/api/test.js Normal file
View File

@ -0,0 +1,8 @@
export default function handler(req, res) {
res.status(200).json({
message: 'API is working!',
timestamp: new Date().toISOString(),
method: req.method,
url: req.url
})
}

View File

@ -1,6 +1,5 @@
import Head from 'next/head'
import dynamic from 'next/dynamic'
import { useState, useEffect } from 'react'
// Dynamically import the chess app to avoid SSR issues with Pusher
const ChessApp = dynamic(() => import('../components/ChessApp'), {
@ -17,59 +16,6 @@ const ChessApp = dynamic(() => import('../components/ChessApp'), {
})
export default function Home() {
const [healthStatus, setHealthStatus] = useState(null)
const [loading, setLoading] = useState(true)
useEffect(() => {
// Check API health on mount
fetch('/api/health')
.then(res => res.json())
.then(data => {
setHealthStatus(data)
setLoading(false)
})
.catch(error => {
console.error('Health check failed:', error)
setHealthStatus({ status: 'error', error: error.message })
setLoading(false)
})
}, [])
if (loading) {
return (
<div className="min-h-screen bg-gradient-to-b from-green-900 to-gray-900 text-green-100 flex items-center justify-center">
<div className="text-center">
<div className="text-6xl mb-4">🍄</div>
<div>Checking system health...</div>
</div>
</div>
)
}
if (healthStatus?.status === 'unhealthy') {
return (
<div className="min-h-screen bg-gradient-to-b from-red-900 to-gray-900 text-red-100 flex items-center justify-center">
<div className="text-center max-w-md mx-auto p-6">
<div className="text-6xl mb-4"></div>
<h1 className="text-2xl font-bold mb-4">System Error</h1>
<div className="bg-red-800 p-4 rounded mb-4 text-left">
<p className="text-sm mb-2"><strong>Error:</strong> {healthStatus.error}</p>
<p className="text-sm mb-2"><strong>Environment Check:</strong></p>
<ul className="text-xs space-y-1">
<li>Supabase URL: {healthStatus.environment?.hasSupabaseUrl ? '✅' : '❌'}</li>
<li>Supabase Key: {healthStatus.environment?.hasSupabaseKey ? '✅' : '❌'}</li>
<li>Pusher Key: {healthStatus.environment?.hasPusherKey ? '✅' : '❌'}</li>
<li>Pusher Cluster: {healthStatus.environment?.hasPusherCluster ? '✅' : '❌'}</li>
</ul>
</div>
<p className="text-sm text-gray-300">
Please check your environment variables and database setup.
</p>
</div>
</div>
)
}
return (
<>
<Head>

9
pages/test.js Normal file
View File

@ -0,0 +1,9 @@
export default function TestPage() {
return (
<div style={{ padding: '20px', fontFamily: 'Arial, sans-serif' }}>
<h1>Test Page Working!</h1>
<p>If you can see this, basic routing is working.</p>
<p>Current time: {new Date().toISOString()}</p>
</div>
)
}