mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
fix(nuxi): show base url in terminal (#5337)
Co-authored-by: Pooya Parsa <pooya@pi0.io>
This commit is contained in:
parent
01700002d8
commit
100dfa6653
@ -34,6 +34,7 @@ export default defineNuxtCommand({
|
||||
}
|
||||
|
||||
const listener = await listen(serverHandler, {
|
||||
showURL: false,
|
||||
clipboard: args.clipboard,
|
||||
open: args.open || args.o,
|
||||
port: args.port || args.p || process.env.NUXT_PORT,
|
||||
@ -50,6 +51,12 @@ export default defineNuxtCommand({
|
||||
const { loadNuxt, buildNuxt } = await loadKit(rootDir)
|
||||
|
||||
let currentNuxt: Nuxt
|
||||
const showURL = () => {
|
||||
listener.showURL({
|
||||
// TODO: Normalize URL with trailing slash within schema
|
||||
baseURL: withTrailingSlash(currentNuxt?.options.app.baseURL) || '/'
|
||||
})
|
||||
}
|
||||
const load = async (isRestart: boolean, reason?: string) => {
|
||||
try {
|
||||
loadingMessage = `${reason ? reason + '. ' : ''}${isRestart ? 'Restarting' : 'Starting'} nuxt...`
|
||||
@ -61,6 +68,10 @@ export default defineNuxtCommand({
|
||||
await currentNuxt.close()
|
||||
}
|
||||
currentNuxt = await loadNuxt({ rootDir, dev: true, ready: false })
|
||||
if (!isRestart) {
|
||||
showURL()
|
||||
}
|
||||
|
||||
await currentNuxt.ready()
|
||||
await currentNuxt.hooks.callHook('listen', listener.server, listener)
|
||||
await Promise.all([
|
||||
@ -70,7 +81,7 @@ export default defineNuxtCommand({
|
||||
currentHandler = currentNuxt.server.app
|
||||
if (isRestart && args.clear !== false) {
|
||||
showBanner()
|
||||
listener.showURL()
|
||||
showURL()
|
||||
}
|
||||
} catch (err) {
|
||||
consola.error(`Cannot ${isRestart ? 'restart' : 'start'} nuxt: `, err)
|
||||
|
Loading…
Reference in New Issue
Block a user