Skip to content

Instantly share code, notes, and snippets.

@liyaodong
Created October 26, 2021 08:55
Show Gist options
  • Save liyaodong/a52fd473d50d79fef122d3e38d231bb9 to your computer and use it in GitHub Desktop.
Save liyaodong/a52fd473d50d79fef122d3e38d231bb9 to your computer and use it in GitHub Desktop.
Auth0 with nextjs localhost https issue

The problem

Auth0 require https to view your resources safely. But usually our localhost is http rather than https. Generate a custom cert file may solve this issue but it require changes on nextjs/express level.

If you're facing issue like checks.state argument is missing during auth0 login step please continue to read.

The solution

The https reverse proxy

Caddy is an opensource tool for the local https work, not sure if it's safe enough but it's open source. https://caddyserver.com/

Go download the server and run

./caddy_darwin_amd64 reverse-proxy --from localhost:443 --to localhost:3000

This will start a local https server on https://localhost, you may need give your system password for trust some CERT.

Update auth0 base url on .env.local

AUTH0_BASE_URL='https://localhost'

After those action the issue should be solved. this solution change nothing on your serverside config, simpler compare to other solutions.

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