Skip to content

[Bug] 内置 Web 控制台(端口 8094)静态 JS 文件以 application/octet-stream 返回,导致页面空白 #1204

Description

@Rilomilo

现象

在局域网内访问设备上 Operit 内置的 Web 控制面板(http://<device-ip>:8094/),页面完全空白,没有任何内容渲染出来。

根因排查

index.html 本身返回正常:

$ curl -v http://192.168.0.117:8094/
< HTTP/1.1 200 OK
< Content-Type: text/html
...
<!doctype html>
<html lang="zh-CN">
  <head>
    ...
    <title>Operit AI</title>
    <script type="module" crossorigin src="/assets/index-DlymrJ6L.js"></script>
    <link rel="stylesheet" crossorigin href="/assets/index-dB-Q6gRC.css">
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>

但它引用的 <script type="module"> 入口文件返回的 Content-Type 是 application/octet-stream,而不是 application/javascript / text/javascript:

$ curl -I http://192.168.0.117:8094/assets/index-DlymrJ6L.js
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 579435
...

浏览器对 type="module" 的脚本会做严格 MIME 类型校验,收到 application/octet-stream 会直接拒绝执行,控制台报错:

Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.

脚本没有执行,#root 元素里就一直是空的,页面表现为完全空白(用无头浏览器验证 document.getElementById('root').innerHTML 长度为 0)。CSS 和 favicon 等其他静态资源的 MIME 类型是正常的,问题只出在 .js 文件上。

建议

内置的静态文件服务器需要为 .js(以及可能的其他前端资源扩展名)返回正确的 Content-Type,而不是统一兜底成 application/octet-stream。

环境

  • Operit Web 控制面板,本地局域网直接访问 8094 端口
  • 复现方式:任意浏览器直接打开该地址即可复现(空白页 + 控制台报错)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions