mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 17:35:57 +00:00
fix(nuxi): allow starting nuxi dev
with self signed certificate (#1699)
This commit is contained in:
parent
de04b321d4
commit
292b5243c7
@ -31,6 +31,23 @@ npm run dev
|
|||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
|
To start Nuxt in development mode with HTTPS <https://localhost:3000> (self-signed certificate):
|
||||||
|
|
||||||
|
::code-group
|
||||||
|
|
||||||
|
```bash [Yarn]
|
||||||
|
yarn dev --https
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash [NPM]
|
||||||
|
npm run dev -- --https
|
||||||
|
```
|
||||||
|
|
||||||
|
::
|
||||||
|
::alert
|
||||||
|
`options.server` from `nuxt.config` is not supported. You can use `--port`, `--host`, `--https`, `--ssl-cert` and `--ssl-key` instead.
|
||||||
|
::
|
||||||
|
|
||||||
## Building for production
|
## Building for production
|
||||||
|
|
||||||
To build your Nuxt application for production, run:
|
To build your Nuxt application for production, run:
|
||||||
|
@ -14,10 +14,17 @@ export default {
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
*
|
||||||
|
* @version 2
|
||||||
|
*
|
||||||
|
* @deprecated This option is ignored with Bridge and Nuxt 3
|
||||||
*/
|
*/
|
||||||
https: false,
|
https: false,
|
||||||
|
/** @deprecated This option is ignored with Bridge and Nuxt 3 */
|
||||||
port: process.env.NUXT_PORT || process.env.PORT || process.env.npm_package_config_nuxt_port || 3000,
|
port: process.env.NUXT_PORT || process.env.PORT || process.env.npm_package_config_nuxt_port || 3000,
|
||||||
|
/** @deprecated This option is ignored with Bridge and Nuxt 3 */
|
||||||
host: process.env.NUXT_HOST || process.env.HOST || process.env.npm_package_config_nuxt_host || 'localhost',
|
host: process.env.NUXT_HOST || process.env.HOST || process.env.npm_package_config_nuxt_host || 'localhost',
|
||||||
|
/** @deprecated This option is ignored with Bridge and Nuxt 3 */
|
||||||
socket: process.env.UNIX_SOCKET || process.env.npm_package_config_unix_socket,
|
socket: process.env.UNIX_SOCKET || process.env.npm_package_config_unix_socket,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,5 +35,6 @@ export default {
|
|||||||
* Currently, only `total` is supported (which directly tracks the whole
|
* Currently, only `total` is supported (which directly tracks the whole
|
||||||
* time spent on server-side rendering.
|
* time spent on server-side rendering.
|
||||||
*/
|
*/
|
||||||
|
/** @deprecated This option is ignored with Bridge and Nuxt 3 */
|
||||||
timing: (val: any) => val ? ({ total: true, ...val }) : false
|
timing: (val: any) => val ? ({ total: true, ...val }) : false
|
||||||
}
|
}
|
||||||
|
@ -13,26 +13,23 @@ import { defineNuxtCommand } from './index'
|
|||||||
export default defineNuxtCommand({
|
export default defineNuxtCommand({
|
||||||
meta: {
|
meta: {
|
||||||
name: 'dev',
|
name: 'dev',
|
||||||
usage: 'npx nuxi dev [rootDir] [--clipboard] [--open, -o] [--port, -p] [--host, -h] [--ssl-cert] [--ssl-key]',
|
usage: 'npx nuxi dev [rootDir] [--clipboard] [--open, -o] [--port, -p] [--host, -h] [--https] [--ssl-cert] [--ssl-key]',
|
||||||
description: 'Run nuxt development server'
|
description: 'Run nuxt development server'
|
||||||
},
|
},
|
||||||
async invoke (args) {
|
async invoke (args) {
|
||||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development'
|
||||||
const https = !!(args['ssl-cert'] && args['ssl-key'])
|
|
||||||
const server = createServer()
|
const server = createServer()
|
||||||
const listener = await server.listen({
|
const listener = await server.listen({
|
||||||
clipboard: args.clipboard,
|
clipboard: args.clipboard,
|
||||||
open: args.open || args.o,
|
open: args.open || args.o,
|
||||||
port: args.port || args.p,
|
port: args.port || args.p,
|
||||||
hostname: args.host || args.h,
|
hostname: args.host || args.h,
|
||||||
...(https && {
|
https: Boolean(args.https),
|
||||||
https,
|
certificate: (args['ssl-cert'] && args['ssl-key']) && {
|
||||||
certificate: {
|
|
||||||
cert: args['ssl-cert'],
|
cert: args['ssl-cert'],
|
||||||
key: args['ssl-key']
|
key: args['ssl-key']
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
const rootDir = resolve(args._[0] || '.')
|
const rootDir = resolve(args._[0] || '.')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user