55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
import { defineConfig } from 'astro/config';
|
|
import dotenv from 'dotenv';
|
|
|
|
// Environment detection
|
|
const isProd = process.env.NODE_ENV === 'production';
|
|
|
|
dotenv.config();
|
|
|
|
export default defineConfig({
|
|
output: 'server', // Change to 'server' if you need SSR
|
|
|
|
adapter: node({
|
|
mode: 'standalone'
|
|
}),
|
|
// Development server settings
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 4321,
|
|
// Only allow local network in dev mode
|
|
middleware: [
|
|
// Middleware to check IP addresses
|
|
(req, res, next) => {
|
|
// Skip middleware in production
|
|
if (isProd) return next();
|
|
|
|
const clientIP = req.socket.remoteAddress || '';
|
|
// Allow local IPs and 192.168.1.x
|
|
if (
|
|
clientIP === '127.0.0.1' ||
|
|
clientIP === '::1' ||
|
|
clientIP.startsWith('192.168.1.')
|
|
) {
|
|
next();
|
|
} else {
|
|
res.statusCode = 403;
|
|
res.end('Access denied: Your IP is not in the allowed range (192.168.1.0/24)');
|
|
}
|
|
}
|
|
]
|
|
},
|
|
|
|
// Vite configuration
|
|
vite: {
|
|
server: {
|
|
// Allow domain for production
|
|
allowedHosts: ['juchatz.com', 'www.juchatz.com'],
|
|
|
|
// Production port (different from dev)
|
|
hmr: {
|
|
port: isProd ? 8080 : 4321
|
|
}
|
|
}
|
|
}
|
|
});
|