HTTPS Local Development Setup

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/:

✅ Domain auth.localdev.com is configured in /etc/hosts to point to 127.0.0.1

Available HTTPS Servers

Backend (Login System)

Frontend (Main Site)

Quick Start

Option 1: Start Both Servers Together

npm run dev:https

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)

npm run serve:https

Access URLs

Backend (Authentication System)

Frontend (Main Site)

Certificate Details

Browser Security Notice

Since these are self-signed certificates, your browser will show a security warning. To proceed:

  1. Click “Advanced” or “Show Details”
  2. Click “Proceed to auth.localdev.com (unsafe)” or similar
  3. The site will work normally after accepting the certificate

Development Workflow

  1. Start HTTPS servers: npm run dev:https
  2. Access backend: https://auth.localdev.com:3001/
  3. Access frontend: https://localhost:3444/
  4. Stop servers: Press Ctrl+C in the terminal

Troubleshooting

Certificate Errors

If you get certificate errors:

  1. Verify certificates exist: ls -la login/certs/
  2. Check file permissions: certificates should be readable
  3. Ensure domain is in hosts file: grep auth.localdev.com /etc/hosts

Port Conflicts

If ports are already in use:

  1. Check what’s using the ports: lsof -i :3001 or lsof -i :3444
  2. Kill the processes or change ports in the server files

CORS Issues

If you encounter CORS errors:

  1. Check the allowedOrigins configuration in login/utils/cors-config.js
  2. 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

Next Steps

For production deployment:

  1. Obtain proper SSL certificates from a trusted CA
  2. Configure your production server with the real certificates
  3. Update CORS origins to include your production domain
  4. Ensure proper security headers are set

SUBSCRIBE TO RECEIVE POSTS DIRECTLY TO YOUR INBOX