Home > AI > Frontend > Next.js >

Update Next.js to use HTTPS

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:

  1. Downloaded three SSL files and placed them in the ssl folder.
  2. 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".
  3. Synced to the server using rsync.
  4. Executed npm run dev on the VPS server.

Miraculously, I can now access https://english92.com:3000.



Leave a Reply