HTTPS Local Development Setup
This guide explains how to use HTTPS for local development with your generated SSL certificates.
Prerequisites
â
SSL certificates are already generated and located in login/certs/:
auth.localdev.com-key.pem (private key)
auth.localdev.com.pem (certificate)
â
Domain auth.localdev.com is configured in /etc/hosts to point to 127.0.0.1
Available HTTPS Servers
Backend (Login System)
- Development:
login/https-dev-server.js (Port 3001)
- Production:
login/https-server.js (Port 3001)
Frontend (Main Site)
- HTTPS Server:
frontend-https-server.js (Port 3444)
Quick Start
Option 1: Start Both Servers Together
This will start both the backend and frontend HTTPS servers simultaneously.
Option 2: Start Servers Individually
Backend Only (Login System)
cd login
npm run dev:https
Frontend Only (Main Site)
Access URLs
Backend (Authentication System)
- Main URL: https://auth.localdev.com:3001/
- Admin Panel: https://auth.localdev.com:3001/admin
- Password Reset: https://auth.localdev.com:3001/reset-password
- Config Manager: https://auth.localdev.com:3001/config-manager
- Health Check: https://auth.localdev.com:3001/health
Frontend (Main Site)
- Main URL: https://localhost:3444/
- Health Check: https://localhost:3444/health
Certificate Details
- Domain: auth.localdev.com
- Certificate Type: Self-signed (for local development)
- Key Size: 2048-bit RSA
- Valid For: Local development only
Browser Security Notice
Since these are self-signed certificates, your browser will show a security warning. To proceed:
- Click âAdvancedâ or âShow Detailsâ
- Click âProceed to auth.localdev.com (unsafe)â or similar
- The site will work normally after accepting the certificate
Development Workflow
- Start HTTPS servers:
npm run dev:https
- Access backend: https://auth.localdev.com:3001/
- Access frontend: https://localhost:3444/
- Stop servers: Press
Ctrl+C in the terminal
Troubleshooting
Certificate Errors
If you get certificate errors:
- Verify certificates exist:
ls -la login/certs/
- Check file permissions: certificates should be readable
- Ensure domain is in hosts file:
grep auth.localdev.com /etc/hosts
Port Conflicts
If ports are already in use:
- Check whatâs using the ports:
lsof -i :3001 or lsof -i :3444
- Kill the processes or change ports in the server files
CORS Issues
If you encounter CORS errors:
- Check the
allowedOrigins configuration in login/utils/cors-config.js
- Ensure your frontend is accessing the correct backend URL
Environment Variables
You can customize the HTTPS port by setting:
export HTTPS_PORT=3001 # For backend
Security Notes
- These certificates are for local development only
- Never use self-signed certificates in production
- The private key should remain secure and not be committed to version control
- Certificate files are already in
.gitignore
Next Steps
For production deployment:
- Obtain proper SSL certificates from a trusted CA
- Configure your production server with the real certificates
- Update CORS origins to include your production domain
- Ensure proper security headers are set