-
Notifications
You must be signed in to change notification settings - Fork 297
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (22 loc) · 977 Bytes
/
server.js
File metadata and controls
28 lines (22 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Custom Next.js server with extended timeout for video generation
// Node.js default server.requestTimeout is 5 minutes (300,000ms)
// We extend it to 10 minutes for long-running fal.ai video generation
const { createServer } = require('http');
const next = require('next');
const dev = process.env.NODE_ENV !== 'production';
const hostname = 'localhost';
const port = process.env.PORT || 3000;
const app = next({ dev, hostname, port });
const handle = app.getRequestHandler();
app.prepare().then(() => {
const server = createServer(async (req, res) => {
await handle(req, res);
});
// Increase timeout to 10 minutes for long-running video generation
server.requestTimeout = 600000; // 10 minutes
server.headersTimeout = 610000; // Slightly longer than requestTimeout
server.listen(port, () => {
console.log(`> Ready on http://${hostname}:${port}`);
console.log(`> Server timeout set to ${server.requestTimeout / 1000 / 60} minutes`);
});
});