[英]Deploying Nuxt JS SSR app to Google Cloud App Engine Standard
I am unable to deploy my Nuxt JS SSR app to Google Cloud App Engine.我无法将 Nuxt JS SSR 应用程序部署到 Google Cloud App Engine。 The app is able to run locally both in dev and production mode.
该应用程序能够在开发和生产模式下在本地运行。
The Nuxt JS documentation suggests using the app.yaml
as follows: 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'
However, the Google Cloud documentation suggests using nodejs14
as well as the env_variables
for the bucket name which I assume is the same name as the staging bucket automatically created by Google App Engine.但是,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
When deploying with both of these app.yaml
configurations it deploys successfully to Google App Engine however upon visiting the URL for the instance ( myapp.uk.r.appspot.com ) I am met with the error as follows:使用这两种
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.
And when visiting staging.myapp.appspot.com I am met with a range of errors from a generic Google 404 error to a certificate error.在访问staging.myapp.appspot.com 时,我遇到了一系列错误,从一般的 Google 404 错误到证书错误。 Does anyone have any idea about the correct
app.yaml
configuration for deploying a Nuxt JS SSR app to Google Cloud App Engine?有没有人知道将 Nuxt JS SSR 应用程序部署到 Google Cloud App Engine 的正确
app.yaml
配置?
Please check the application logs to make sure whats happen on GAE
请检查应用程序日志以确保
GAE
发生了什么
gcloud app logs tail
Then try my yaml file for nuxt SSR too:然后也试试我的 yaml 文件用于 nuxt SSR:
runtime: nodejs14
service: nuxt
instance_class: F1
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
Does anyone have any idea about the correct app.yaml configuration for deploying a Nuxt JS SSR app to Google Cloud App Engine?
有没有人知道将 Nuxt JS SSR 应用程序部署到 Google Cloud App Engine 的正确 app.yaml 配置?
I replicated your case and deployed the basic tutorial deploying of Nuxt JS app in App Engine using your provided app.yaml
configuration.我复制了您的案例并使用您提供的
app.yaml
配置在 App Engine 中部署了 Nuxt JS 应用程序的基本教程。 Both configuration are working even I reduced the the instance_class
from F2
to F1
, its still working well.即使我将
instance_class
从F2
减少到F1
,这两种配置都可以正常工作,它仍然运行良好。
As of now, the recommended version of nodejs is nodejs14
but the app is still working in App Engine Standard even the version is nodejs10
.截至目前,nodejs 的推荐版本是
nodejs14
但该应用程序仍在 App Engine Standard 中运行,即使版本是nodejs10
。 The env_variables
is optional, you can define environment variables in your app.yaml
file to make them available or use it inside your app. env_variables
是可选的,您可以在app.yaml
文件中定义环境变量以使其可用或在您的应用程序中使用它。
Error:错误:
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
The 500 error
or server error
is hard to find the cause. 500 error
或server error
很难找到原因。 Look for the logs in Cloud Logging or click this link to direct go to console.在Cloud Logging 中查找日志或单击此链接直接转到控制台。 Make sure that you are in GAE application > your service name > App Engine Version .
确保您在GAE application > your service name > App Engine Version 中。 Start looking for error appearing when accessing your application and look for error cause description.
开始查找访问应用程序时出现的错误并查找错误原因描述。 If you haven't find any try to switch to all logs.
如果您还没有找到任何尝试切换到所有日志。
Please note, it also requires the following API is already enabled:请注意,它还需要已启用以下 API:
Additional troubleshooting, double check the listening port on your application.其他故障排除,仔细检查应用程序上的侦听端口。
Solved the issue it seems to have been an oversight regarding specifying a different server port in nuxt.config.js of 8000 rather than the default.解决了这个问题,似乎是疏忽了在 nuxt.config.js 中指定不同的服务器端口 8000 而不是默认值。
By looking at the logs using:通过查看日志使用:
gcloud app logs tail
This error became apparent:这个错误变得明显:
✖ Nuxt Fatal Error
Error: listen EADDRNOTAVAIL: address not available *.*.*.*:8000
Try this configuration:试试这个配置:
runtime: nodejs12
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'
I have an nuxt app running in App Engine, and this is my Yaml config.我有一个在 App Engine 中运行的 nuxt 应用程序,这是我的 Yaml 配置。
I suggest you to check if your application is Enabled in GCP/App Engine/Configurations=> Deactivate App field.我建议您检查您的应用程序是否在 GCP/App Engine/Configurations=> Deactivate App字段中启用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.