Update Astro configuration to use Fastify adapter and include prefetch integration
- Replaced the Node adapter with Fastify for improved performance. - Added the @astrojs/prefetch integration to enhance resource loading. - Updated server settings to adjust logging level and minification options. - Modified package.json to include new dependencies for Fastify and prefetch.
This commit is contained in:
22
server.js
Normal file
22
server.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import express from 'express';
|
||||
import compression from 'compression';
|
||||
import { handler } from './dist/server/entry.mjs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
// Enable gzip/brotli compression
|
||||
app.use(compression());
|
||||
|
||||
// Serve static assets from the dist/client directory
|
||||
app.use(express.static(path.join(__dirname, 'dist/client')));
|
||||
|
||||
// Handle all SSR requests with Astro's handler
|
||||
app.all('*', handler);
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Server running with compression on http://localhost:${PORT}`);
|
||||
});
|
Reference in New Issue
Block a user