This commit is contained in:
greg 2025-04-27 21:40:21 +02:00
parent 89373c84f8
commit f3e87f2b9c
5 changed files with 124 additions and 44 deletions

View File

@ -0,0 +1 @@
web: npm start

View File

@ -17,6 +17,7 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"date-fns": "^3.3.1",
"express": "^4.18.2",
"lucide-react": "^0.358.0",
"next": "14.1.0",
"react": "^18.2.0",

View File

@ -1,39 +1,66 @@
const { createServer } = require('http');
const { parse } = require('url');
// Simple Express server for more reliable deployment
const express = require('express');
const next = require('next');
const path = require('path');
// Set up environment variables with defaults
const dev = process.env.NODE_ENV !== 'production';
const hostname = process.env.HOSTNAME || '0.0.0.0';
const port = parseInt(process.env.PORT || '3000', 10);
// Prepare the Next.js app
const app = next({ dev, hostname, port });
// Create the Next.js app instance with minimal configuration
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare().then(() => {
console.log(`Next.js App is preparing to start...`);
// Log memory usage for debugging
const logMemoryUsage = () => {
const memoryUsage = process.memoryUsage();
console.log('Memory usage:');
console.log(` RSS: ${Math.round(memoryUsage.rss / 1024 / 1024)} MB`);
console.log(` Heap total: ${Math.round(memoryUsage.heapTotal / 1024 / 1024)} MB`);
console.log(` Heap used: ${Math.round(memoryUsage.heapUsed / 1024 / 1024)} MB`);
};
createServer(async (req, res) => {
try {
// Parse the URL
const parsedUrl = parse(req.url, true);
// Let Next.js handle the request
await handle(req, res, parsedUrl);
} catch (err) {
console.error('Error occurred handling request:', err);
res.statusCode = 500;
res.end('Internal Server Error');
}
})
.once('error', (err) => {
console.error('Server error:', err);
process.exit(1);
})
.listen(port, hostname, () => {
console.log(`> Ready on http://${hostname}:${port}`);
});
}).catch((err) => {
console.error('Next.js app preparation failed:', err);
process.exit(1);
// Handle uncaught exceptions
process.on('uncaughtException', (err) => {
console.error('Uncaught exception:', err);
logMemoryUsage();
});
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
logMemoryUsage();
});
// Simple health check response
const healthCheck = (req, res) => {
res.status(200).json({ status: 'ok', timestamp: new Date().toISOString() });
};
app.prepare()
.then(() => {
const server = express();
// Add health check endpoint
server.get('/health', healthCheck);
server.get('/api/health', healthCheck);
// Serve static files from the public directory
server.use(express.static(path.join(__dirname, 'public')));
// Let Next.js handle all other routes
server.all('*', (req, res) => {
return handle(req, res);
});
// Start the server
server.listen(port, '0.0.0.0', (err) => {
if (err) throw err;
console.log(`> Ready on port ${port} - env ${process.env.NODE_ENV || 'development'}`);
logMemoryUsage();
});
})
.catch((ex) => {
console.error('An error occurred starting the app:', ex);
logMemoryUsage();
process.exit(1);
});

View File

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Favorites - Maintenance</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background-color: #f5f5f0;
color: #333;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
padding: 20px;
text-align: center;
}
.container {
max-width: 600px;
padding: 40px;
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #3b82f6;
margin-bottom: 16px;
}
p {
line-height: 1.6;
margin-bottom: 24px;
}
</style>
</head>
<body>
<div class="container">
<h1>My Favorites</h1>
<p>Our application is currently undergoing maintenance. We'll be back shortly with a collection of books, movies, series, and more that have made an impression.</p>
<p>Thank you for your patience!</p>
</div>
</body>
</html>

View File

@ -1,16 +1,11 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import { Header } from "@/components/Header";
import { Inter } from "next/font/google";
import "./globals.css";
const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
});
const geistMono = Geist_Mono({
variable: "--font-geist-mono",
// Use Inter font instead of Geist for better compatibility
const inter = Inter({
subsets: ["latin"],
display: "swap",
});
export const metadata: Metadata = {
@ -25,11 +20,22 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased min-h-screen bg-background`}
>
<body className={`${inter.className} antialiased min-h-screen bg-background`}>
<div className="relative flex min-h-screen flex-col">
<Header />
<header className="sticky top-0 z-50 w-full border-b bg-background/95 backdrop-blur">
<div className="container flex h-16 items-center">
<div className="mr-4 flex">
<a href="/" className="flex items-center space-x-2">
<span className="text-xl font-bold">My Favorites</span>
</a>
</div>
<div className="flex flex-1 items-center justify-end">
<nav className="flex items-center space-x-2">
<a href="/admin" className="px-4 py-2 text-sm font-medium hover:underline">Admin</a>
</nav>
</div>
</div>
</header>
<main className="flex-1">
<div className="container py-6 md:py-10">
{children}