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

在Google App Engine部署Vue.js应用访问时出现404错误如何解决?

解决方法
  • 优先检查.gcloudignore和.gitignore文件,90%以上的该类问题都是dist文件夹被忽略规则拦截,部署时没有上传到GAE导致。如果两个文件中存在dist、dist/这类匹配规则,直接删除对应规则,或者在.gcloudignore中添加!dist/规则强制上传dist目录。
  • 确认部署操作在app.yaml所在的根目录执行,且执行部署前已经运行npm run build生成了完整的dist目录及内部文件,不要在dist目录下执行部署命令。
  • 可以在部署命令中添加参数查看上传的文件列表,确认dist/index.html被正常上传:
    gcloud app deploy --verbosity=info
  • 如果排查完上传问题依然报错,可替换原有handlers配置为更通用的Vue部署规则:
runtime: nodejs12
instance_class: F2

handlers:
- url: /(.*\..+)$
  static_files: dist/\1
  upload: dist/.*\..+$
  expiration: "30d"
- url: /.*
  static_files: dist/index.html
  upload: dist/index.html

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.28 20:45:07