Initial commit
This commit is contained in:
48
astro.config.mjs
Normal file
48
astro.config.mjs
Normal file
@@ -0,0 +1,48 @@
|
||||
import { defineConfig } from 'astro/config';
|
||||
|
||||
// Environment detection
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
|
||||
export default defineConfig({
|
||||
output: 'static', // Change to 'server' if you need SSR
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user