Skip to content

Instantly share code, notes, and snippets.

@ralavay
Created June 9, 2018 15:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ralavay/5d74d35859f87d22c74984488f20186c to your computer and use it in GitHub Desktop.
Save ralavay/5d74d35859f87d22c74984488f20186c to your computer and use it in GitHub Desktop.
Run local development as HTTPS to handle Facebook app login enforce HTTPS

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

  1. Set dev.yourdomain.com DNS point to 127.0.0.1

Can add this to /etc/hosts or just set it in your DNS provider.

  1. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment