When using NextAuth.js
with the Google Provider, Google recommends that the Authorized redirect URIs
use HTTPS
. This raises the question of how to convert a Next.js project to HTTPS.
This thread https://github.com/vercel/next.js/discussions/10935 proposes my exact question.
Based on this insight, I followed these steps:
- Downloaded three SSL files and placed them in the
ssl
folder. - Updated
package.json
from"dev": "next dev"
to"dev": "next dev --experimental-https --experimental-https-key ./ssl/key.pem --experimental-https-cert ./ssl/cert.pem --experimental-https-ca ./ssl/server.ca"
. - Synced to the server using
rsync
. - Executed
npm run dev
on the VPS server.
Miraculously, I can now access https://english92.com:3000.