我无法将 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 自动创建的临时存储桶名称相同应用程序引擎。
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
配置吗?
最佳答案
Does anyone have any idea about the correct app.yaml configuration for deploying a Nuxt JS SSR app to Google Cloud App Engine?
我复制了您的案例,并使用您提供的 app.yaml
配置在 App Engine 中部署了 Nuxt JS 应用程序的基本教程。即使我将 instance_class
从 F2
减少到 F1
,这两种配置都可以正常工作,但它仍然工作良好。
截至目前,推荐的 Nodejs 版本是 nodejs14
,但即使版本是 nodejs10
,该应用仍然可以在 App Engine Standard 中运行。 env_variables
是可选的,您可以在 app.yaml
文件中定义环境变量以使其可用或在您的应用程序中使用它。
错误:
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
500错误
或服务器错误
很难找到原因。在 Cloud Logging 中查找日志或点击此link直接转到控制台。确保您位于GAE 应用程序> 您的服务名称> App Engine 版本。开始查找访问应用程序时出现的错误并查找错误原因描述。如果您没有找到任何日志,请尝试切换到所有日志。
请注意,它还需要已启用以下 API:
- App Engine API
- 计算引擎 API
- 云构建 API
其他故障排除,请仔细检查应用程序上的监听端口。
关于node.js - 将 Nuxt JS SSR 应用部署到 Google Cloud App Engine Standard,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68385121/