【问题标题】:Deploy Vuejs App on Google App Engine get 404 error在 Google App Engine 上部署 Vuejs 应用程序得到 404 错误
【发布时间】:2021-10-27 06:18:37
【问题描述】:

我正在 App Engine 上部署一个 Vuejs 应用程序,部署后当我访问应用程序链接时出现 404 错误:

在日志中我看到了这个错误:

找不到处理程序引用的静态文件:dist/index.html

App Engine 上的文件结构是:

  • 应用引擎
    • 分布
      • index.html
    • app.yaml

我的 App.yaml 文件:

runtime: nodejs12

instance_class: F2

handlers:
# Serve all static files with urls ending with a file extension
- url: /(.*\..+)$ 
  static_files: dist/\1
  upload: dist/(.*\..+)$
  # catch all handler to index.html
- url: /.*
  static_files: dist/index.html
  upload: dist/index.html

我尝试上传一个测试文件夹并在其中创建一个 index.html 文件并将处理程序 URL 更改为指向测试文件夹,它可以工作,但是对于 dist 文件夹它不起作用。 对这个问题有帮助吗?

【问题讨论】:

    标签: vue.js google-app-engine deployment


    【解决方案1】:

    您可以尝试将您的App.yaml 更改为

    runtime: nodejs12
    
    instance_class: F2
    
    handlers:
    # Serve all static files with urls ending with a file extension
    - url: /(.*\..+)$ 
      static_files: dist/\1
      upload: dist/(.*\..+)$
      # catch all handler to index.html
    
    
    

    您用于 URL 的 RE 应涵盖所有目录。如果您只想查询特定的扩展名,可以查看following documentation。

    【讨论】:

    • 它不起作用,我猜 AppEngine 在 dist 文件夹存在时看不到它!
    • @Mhm0ud 我已经更新了我的答案。你能检查一下吗?我猜这个问题可能是由于 URL 使用了 2 次 RE。如果它不起作用,请告诉我。我会尝试用不同的解决方案帮助您。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-21
    • 2019-04-22
    • 1970-01-01
    • 2019-05-18
    相关资源
    最近更新 更多