You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Wrangler Pages部署Qwik网站时出现文件找不到的404问题

环境信息
  • Wrangler版本: 8.19.1
  • 操作系统: Ubuntu 22.04.1 LTS
问题描述

在Qwik Pages项目中执行npm run build && npm run serve命令后,多个文件返回404无法访问:

DevTools控制台完整输出

127.0.0.1/:1 
 GET http://127.0.0.1:8788/build/q-8b482804.css net::ERR_ABORTED 404 (Not Found)
127.0.0.1/:1 
 GET http://127.0.0.1:8788/build/q-9f65a413.css net::ERR_ABORTED 404 (Not Found)
127.0.0.1/:1 
 GET http://127.0.0.1:8788/build/q-e6eff275.css net::ERR_ABORTED 404 (Not Found)
127.0.0.1/:1 
 GET http://127.0.0.1:8788/build/q-03a2bd7f.css net::ERR_ABORTED 404 (Not Found)
favicon.ico:1 
 GET http://127.0.0.1:8788/favicon.ico 404 (Not Found)
A bad HTTP response code (404) was received when fetching the script.
(index):3 TypeError: Failed to register a ServiceWorker for scope ('http://127.0.0.1:8788/') with script ('http://127.0.0.1:8788/service-worker.js'): A bad HTTP response code (404) was received when fetching the script.

终端完整输出

npm run serve                                                                                                                         [14:02:45]

> serve
> wrangler pages dev ./dist

🚧 'wrangler pages <command>' is a beta command.
Compiling worker to "/tmp/functionsWorker-0.3009066340734492.js"...
Compiled Worker successfully.
▲ [WARNING] Passing --inspect is unnecessary, now you can always connect to devtools.

Starting inspector on 0.0.0.0:9229 failed: address already in use
GET / 200 OK (28.51ms)
GET /build/q-8b482804.css 404 Not Found (99.78ms)
GET /build/q-9f65a413.css 404 Not Found (69.33ms)
GET /build/q-e6eff275.css 404 Not Found (57.81ms)
GET /build/q-03a2bd7f.css 404 Not Found (57.55ms)
GET /service-worker.js 404 Not Found (53.69ms)
GET /favicon.ico 404 Not Found (61.71ms)

已尝试的修复操作:

  • 将entry.cloudflare-pages.tsx中已弃用的qwikCity替换为新的createQwikCity,无任何改善
  • 尝试先执行npm run build.server再运行serve命令,问题依旧
  • 确认缺失的文件确实存在于./dist目录中,但访问时仍返回404,无额外错误提示

补充说明:执行npm run dev命令时,网站运行完全正常。


内容的提问来源于stack exchange,提问作者Joshua Bruylant

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 03:10:56