Facebook enforces to use HTTPS for Facebook Login so we can't you http://localhost:port
in local anymore.
We will just get this message
Insecure Login Blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https://
How to run your local development with HTTPS
- Set
dev.yourdomain.com
DNS point to127.0.0.1
Can add this to /etc/hosts
or just set it in your DNS provider.
- Use a proxy in your local to handle HTTPS
Recommend Caddy https://caddyserver.com since it is very simple and support multiple platforms.
With a Caddyfile
like this
dev.yourdomain.com.tw:443 {
tls self_signed
proxy /api localhost:3000
proxy / localhost:8080
}
Then run Caddy with this config
# Need sudo permission to run on port 443
sudo ./caddy --conf /path/to/the/Caddyfile/above
You can do proxy to API /api
to localhost:3000
and the frontend to localhost:8080
.
Some browser like FireFox, Safari, Brave, etc still allow you to ignore self-signed SSL.