Unverified Commit a5ae1a66 authored by Lee Robinson's avatar Lee Robinson Committed by GitHub

docs: Add docs for `next dev --experimental-https` (#60357)

parent f6c5e2f8
...@@ -91,6 +91,22 @@ You can also set the hostname to be different from the default of `0.0.0.0`, thi ...@@ -91,6 +91,22 @@ You can also set the hostname to be different from the default of `0.0.0.0`, thi
npx next dev -H 192.168.1.2 npx next dev -H 192.168.1.2
``` ```
### HTTPS for Local Development
For certain use cases like webhooks or authentication, it may be required to use HTTPS to have a secure environment on `localhost`. Next.js can generate a self-signed certificate with `next dev` as follows:
```bash filename="Terminal"
next dev --experimental-https
```
You can also provide a custom certificate and key with `--experimental-https-key` and `--experimental-https-cert`. Optionally, you can provide a custom CA certificate with `--experimental-https-ca` as well.
```bash filename="Terminal"
next dev --experimental-https --experimental-https-key ./certificates/localhost-key.pem --experimental-https-cert ./certificates/localhost.pem
```
`next dev --experimental-https` is only intended for development and creates a locally-trusted certificate with `mkcert`. In production, use properly issued certificates from trusted authorities. When deploying to Vercel, HTTPS is [automatically configured](https://vercel.com/docs/security/encryption) for your Next.js application.
## Production ## Production
`next start` starts the application in production mode. The application should be compiled with [`next build`](#build) first. `next start` starts the application in production mode. The application should be compiled with [`next build`](#build) first.
......
...@@ -125,10 +125,14 @@ const nextDev: CliCommand = async (args) => { ...@@ -125,10 +125,14 @@ const nextDev: CliCommand = async (args) => {
If no directory is provided, the current directory will be used. If no directory is provided, the current directory will be used.
Options Options
--port, -p A port number on which to start the application --port, -p A port number to start the application on
--hostname, -H Hostname on which to start the application (default: 0.0.0.0) --hostname, -H Hostname start the application on (default: 0.0.0.0)
--experimental-upload-trace=<trace-url> [EXPERIMENTAL] Report a subset of the debugging trace to a remote http url. Includes sensitive data. Disabled by default and url must be provided. --experimental-https Start the server with HTTPS and generate a self-signed certificate
--help, -h Displays this message --experimental-https-key <path> Path to a HTTPS key file
--experimental-https-cert <path> Path to a HTTPS certificate file
--experimental-https-ca <path> Path to a HTTPS certificate authority file
--experimental-upload-trace=<trace-url> Report a subset of the debugging trace to a remote http url. Includes sensitive data. Disabled by default and url must be provided.
--help, -h Displays this message
`) `)
process.exit(0) process.exit(0)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment