Dev Server HTTPS Needed for Secure Features
Features requiring HTTPS (geolocation, service workers, secure cookies) don't work on localhost:5173. Browser blocks insecure context APIs. Need to test HTTPS-only features in development.
Development typically uses HTTP, but some APIs require HTTPS. Self-signed certificates enable local HTTPS testing.
Error Messages You Might See
Common Causes
- Dev server only running HTTP, not HTTPS
- No local certificate for HTTPS
- Browser rejects self-signed certificate
- Unsupported feature from non-HTTPS context
- Mixed HTTP/HTTPS requests (mixed content)
How to Fix It
Configure HTTPS in vite.config.js:
import fs from 'fs';
export default {
server: {
https: {
key: fs.readFileSync('.cert/key.pem'),
cert: fs.readFileSync('.cert/cert.pem')
}
}
}Generate self-signed cert: mkcert localhost
Or use localhost.run or ngrok for public HTTPS tunnel.
Real developers can help you.
You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.
Get HelpFrequently Asked Questions
How do I generate a local certificate?
Use mkcert tool: 'mkcert localhost' creates cert.pem and key.pem.
Is self-signed cert safe?
For development only. Add certificate exception in browser or use trusted local CA with mkcert.