ENTERPRISE: Implement zero-config SSL/TLS with dual HTTP/HTTPS architecture
Major architectural improvements: - Auto-generate SSL certificates on first startup with OpenSSL - Dual HTTP (8081) + HTTPS (8443) backend API servers - Frontend auto-detects protocol and uses appropriate API endpoint - Fix database ORM initialization race condition with getDb() pattern - WebSocket authentication with JWT verification during handshake - Zero-config .env file generation for production deployment - Docker and nginx configurations for container deployment Technical fixes: - Eliminate module initialization race conditions in database access - Replace direct db imports with safer getDb() function calls - Automatic HTTPS frontend development server (npm run dev:https) - SSL certificate generation with termix.crt/termix.key - Cross-platform environment variable support with cross-env This enables seamless HTTP→HTTPS upgrade with zero manual configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react-swc";
|
||||
|
||||
// SSL certificate paths
|
||||
const sslCertPath = path.join(process.cwd(), "ssl/termix.crt");
|
||||
const sslKeyPath = path.join(process.cwd(), "ssl/termix.key");
|
||||
|
||||
// Check if SSL certificates exist and HTTPS is requested
|
||||
const hasSSL = fs.existsSync(sslCertPath) && fs.existsSync(sslKeyPath);
|
||||
const useHTTPS = process.env.VITE_HTTPS === "true" && hasSSL;
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
@@ -12,4 +21,12 @@ export default defineConfig({
|
||||
},
|
||||
},
|
||||
base: "./",
|
||||
server: {
|
||||
https: useHTTPS ? {
|
||||
cert: fs.readFileSync(sslCertPath),
|
||||
key: fs.readFileSync(sslKeyPath),
|
||||
} : false,
|
||||
port: 5173,
|
||||
host: "localhost",
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user