dev: false "reachable from the network" warning when `devServer.host` is a `*.localhost` subdomain
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #1649 来自 @paoValle —— 已关闭,未合并
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
- 领域
- cli, networking
调研方向
找到listen的实现,以及使用LOOPBACK_HOSTS.has(hostname)并触发警告和Network:提示的两处检查。阅读这些检查,并查找覆盖主机分类或开发服务器输出的现有测试。在这两处都将.localhost子域视为回环地址;当它们不再触发网络警告,也不再显示为网络 URL 时,即完成。
由索引模型根据 Issue 内容生成。
描述
Environment
@nuxt/cli: 4.0.1nuxt: 4.6.2- Node.js: 24.21.0
- OS: macOS
Reproduction
// nuxt.config.ts
export default defineNuxtConfig({
devServer: { host: 'my-app.localhost' },
})
nuxt dev
Describe the bug
The CLI prints:
The dev server is reachable from the network without authentication: anyone who can connect can read the app, build errors and source code.
The server is not reachable from the network. my-app.localhost resolves to loopback only (dns.lookup('my-app.localhost', { all: true }) returns ::1 and 127.0.0.1), so the listener is bound to loopback just like with localhost.
Per RFC 6761 §6.3, localhost and every name under .localhost resolve to loopback. Browsers resolve them that way without DNS and treat them as secure contexts. *.localhost names are a common way to run several local apps side by side.
Cause
In listen the warning only checks an exact-match set:
const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1'])
// ...
if (announce && (anyHost || !LOOPBACK_HOSTS.has(hostname))) logger.warn('The dev server is reachable from the network ...')
my-app.localhost is not in the set, so it is treated as a public host. The same check also drives the Network: hint shown under the URLs.
Suggested fix
Treat any .localhost name as loopback, e.g.:
const isLoopbackHost = host => LOOPBACK_HOSTS.has(host) || host.endsWith('.localhost')
and use it in both places that currently call LOOPBACK_HOSTS.has(hostname).
Workaround
Leave devServer.host unset and pass --publicURL http://my-app.localhost:3000 to nuxt dev, so the CLI shows that URL without the warning.
- 主要语言
- TypeScript
- 星标
- 402
- 派生
- 125
- 平均合并
- 2 天 9 小时
- 30 天内合并 PR
- 37
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nuxt/cli 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 45/100
维护者通常 1 天内回复
相似的 Issue
-
[Bug]: Search input loses focus while typing on the Inventory, Reservations and Locations lists (view_configurations enabled)可能已有人在做 @medusa-os-bot 今天认领。 未关闭status: needs triaging type: bug version: 2.0
难度 2/5 1-3 小时 新手友好度 86/100
medusajs/medusa#17886 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 95/100
marimo-team/marimo#11949 ·
维护者通常 1 天内回复
-
bug server-time v2
难度 2/5 1-3 小时 新手友好度 76/100
modelcontextprotocol/servers#5559 ·
维护者通常 1 天内回复
-
D1 Time Travel restore help advertises 30 days without a plan qualifier可能已有人在做 @akhil9tiet 今天认领。 未关闭bug package:wrangler product:d1
难度 1/5 1-3 小时 新手友好度 78/100
cloudflare/workers-sdk#17000 · 2 条评论 ·
维护者通常 1 天内回复
-
bug severity:medium triage:confirmed triage:reproduced
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复