1.0 KiB
1.0 KiB
Step 5: Set Up HTTPS with mkcert (macOS)
1. Install mkcert (if not already installed):
brew install mkcert
2. Install local certificate authority:
mkcert -install
3. Create certificates directory:
mkdir certs
mkcert -cert-file certs/localhost+2.pem -key-file certs/localhost+2-key.pem localhost 127.0.0.1 ::1
This creates: • certs/localhost+2.pem (certificate) • certs/localhost+2-key.pem (private key)
4. Install Uvicorn (ASGI server with SSL support):
Ensure you are at the project root and venv is activated:
pip install 'uvicorn[standard]'
5. Update requirements.txt:
pip freeze > requirements.txt
6. Create run.sh script (macOS/Linux):
cat > run.sh << 'EOF'
#!/usr/bin/env bash
uvicorn backend.asgi:application \
--host 127.0.0.1 --port 8000 \
--ssl-keyfile ./certs/localhost+2-key.pem \
--ssl-certfile ./certs/localhost+2.pem
EOF
chmod +x run.sh
Note: Replace backend with your project name if different.