Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
fix(nuxi): read devServer options from nuxt config (#19055)
Browse files Browse the repository at this point in the history
  • Loading branch information
Verequies committed Feb 16, 2023
1 parent 681cfa8 commit c45b842
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
23 changes: 15 additions & 8 deletions packages/nuxi/src/commands/dev.ts
Expand Up @@ -44,20 +44,27 @@ export default defineNuxtCommand({

await setupDotenv({ cwd: rootDir, fileName: args.dotenv })

const { loadNuxt, loadNuxtConfig, buildNuxt } = await loadKit(rootDir)

const config = await loadNuxtConfig({
cwd: rootDir,
overrides: { dev: true }
})

const listener = await listen(serverHandler, {
showURL: false,
clipboard: args.clipboard,
open: args.open || args.o,
port: args.port || args.p || process.env.NUXT_PORT,
hostname: args.host || args.h || process.env.NUXT_HOST,
https: args.https && {
cert: args['ssl-cert'],
key: args['ssl-key']
}
port: args.port || args.p || process.env.NUXT_PORT || config.devServer.port,
hostname: args.host || args.h || process.env.NUXT_HOST || config.devServer.host,
https: (args.https !== false && (args.https || config.devServer.https))
? {
cert: args['ssl-cert'] || (config.devServer.https && config.devServer.https.cert) || undefined,
key: args['ssl-key'] || (config.devServer.https && config.devServer.https.key) || undefined
}
: false
})

const { loadNuxt, buildNuxt } = await loadKit(rootDir)

let currentNuxt: Nuxt
const showURL = () => {
listener.showURL({
Expand Down
7 changes: 5 additions & 2 deletions packages/schema/src/config/dev.ts
Expand Up @@ -28,10 +28,13 @@ export default defineUntypedSchema({
port: process.env.NUXT_PORT || process.env.NITRO_PORT || process.env.PORT || 3000,

/** Dev server listening host */
host: process.env.NUXT_HOST || process.env.NITRO_HOST || process.env.HOST || 'localhost',
host: process.env.NUXT_HOST || process.env.NITRO_HOST || process.env.HOST || '',

/**
* Listening dev server url
* Listening dev server URL.
*
* This should not be set directly as it will always be overridden by the
* dev server with the full URL (for module and internal use).
*/
url: 'http://localhost:3000',
}
Expand Down

0 comments on commit c45b842

Please sign in to comment.