【发布时间】:2021-09-23 20:22:05
【问题描述】:
我无法将我的 Nuxt JS SSR 应用部署到 Google Cloud App Engine。 该应用可以在开发和生产模式下本地运行。
Nuxt JS 文档建议使用app.yaml,如下所示:
runtime: nodejs10
instance_class: F2
handlers:
- url: /_nuxt
static_dir: .nuxt/dist/client
secure: always
- url: /(.*\.(gif|png|jpg|ico|txt))$
static_files: static/\1
upload: static/.*\.(gif|png|jpg|ico|txt)$
secure: always
- url: /.*
script: auto
secure: always
env_variables:
HOST: '0.0.0.0'
但是,Google Cloud 文档建议使用 nodejs14 以及 env_variables 作为存储桶名称,我认为它与 Google App Engine 自动创建的暂存存储桶名称相同。
runtime: nodejs14 # or another supported version
instance_class: F2
env_variables:
BUCKET_NAME: "staging.myapp.appspot.com"
handlers:
- url: /_nuxt
static_dir: .nuxt/dist/client
secure: always
- url: /(.*\.(gif|png|jpg|ico|txt))$
static_files: static/\1
upload: static/.*\.(gif|png|jpg|ico|txt)$
secure: always
- url: /.*
script: auto
secure: always
当使用这两种app.yaml 配置进行部署时,它会成功部署到 Google App Engine,但是在访问实例的 URL (myapp.uk.r.appspot.com) 时,我遇到了错误如下:
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
当我访问 staging.myapp.appspot.com 时,我遇到了从一般的 Google 404 错误到证书错误的一系列错误。有人知道将 Nuxt JS SSR 应用部署到 Google Cloud App Engine 的正确 app.yaml 配置吗?
【问题讨论】:
-
请包含来自 Cloud Logging 的错误详细信息或在终端中使用
gcloud app logs tail,就像 @FauziFadillah 的回答一样。
标签: node.js google-app-engine google-cloud-platform nuxt.js