Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Nuxt DevTools causes 404 error on custom HTTPS domain

未关闭
#925 1 条评论 6 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
nuxt, typescript

调研方向

使用 nuxt.config.ts 中的 HTTPS 自定义域名设置进行复现,然后检查 NUXT_DEVTOOLS_VIEW 周围的 NuxtDevServer.toNodeHandle 和 DevTools 客户端。将其行为与 localhost 进行比较,并运行报告中的设置。完成标准是:自定义 HTTPS 域名能够加载 DevTools,且不会反复出现 /_nuxt/ 404、跨源错误或损坏的面板。

由索引模型根据 Issue 内容生成。

描述

Environment
  • Nuxt: 4.2.2
  • Node: v22.x
  • OS: macOS
  • Custom domain: https://custom.domain.local:3000 (local HTTPS with self-signed certificate)
Reproduction
Setup
npx nuxi init devtools-https-bug
cd devtools-https-bug
npm install
Generate local certificates
# Using mkcert (recommended)
mkcert -install
mkcert custom.domain.local
Configure nuxt.config.ts
export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true },
  devServer: {
    https: {
      key: './custom.domain.local-key.pem',
      cert: './custom.domain.local.pem',
    },
  },
})
Add hosts entry
# Add to /etc/hosts (macOS/Linux) or C:\Windows\System32\drivers\etc\hosts (Windows)
127.0.0.1 custom.domain.local
Development Server

Start the development server:

npm run dev

Open https://custom.domain.local:3000 in the browser.

Describe the bug

When running the Nuxt dev server on a custom HTTPS domain (not localhost), DevTools causes repeated 404 errors in the terminal and a cross-origin error in the browser console.

Terminal error:
ERROR  [request error] [unhandled] [GET] https://custom.domain.local:3000/_nuxt/

ℹ Error: 
 ⁃ at createError (node_modules/@nuxt/cli/dist/dev-KB30iboK.mjs:54:14)
 ⁃ at NuxtDevServer.toNodeHandle (node_modules/@nuxt/cli/dist/dev-KB30iboK.mjs:264:18)

[CAUSE]
{
  status: 404,
}
Browser console error:
SecurityError: Failed to read a named property '__NUXT_DEVTOOLS_VIEW__' from 'Window': Blocked a frame with origin "https://custom.domain.local:3000" from accessing a cross-origin frame.
    at client.js?v=81bfbde2:136:13
Additional context

Expected behavior

DevTools should work without errors on custom HTTPS domains.

Actual behavior

  • Terminal shows repeated /_nuxt/ 404 errors from NuxtDevServer.toNodeHandle
  • Browser console shows cross-origin SecurityError for __NUXT_DEVTOOLS_VIEW__
  • DevTools panel fails to load properly

Workaround

Disabling DevTools eliminates the errors:

devtools: { enabled: false },

Additional context

  • Works fine on https://localhost:3000
  • The issue appears to be DevTools probing /_nuxt/ (bare path with trailing slash) which returns 404
  • May be related to the fix in nuxt/nuxt#31646, but that fix doesn't seem to cover this case
Logs

主要语言
TypeScript
星标
3.3k
派生
214
平均合并
19 小时 45 分钟
30 天内合并 PR
12

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nuxt/devtools 的其他 Issue

查看 nuxt/devtools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。