我無法將我的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'。
然而,谷歌云檔案建議使用nodejs14以及env_variables作為桶的名稱,我認為這與谷歌應用引擎自動創建的staging桶的名稱相同。
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)時,我遇到了如下的錯誤:
myapp.uk.r.appspot.com
Error: 服務器 錯誤。
服務器遇到了一個錯誤,無法完成您的請求。
請 重試 在 30秒。
當訪問staging.myapp.appspot.com時,我遇到了一系列的錯誤,從一個通用的Google 404錯誤到一個證書錯誤。 有沒有人知道在Google Cloud App Engine上部署Nuxt JS SSR應用的正確app.yaml配置?
uj5u.com熱心網友回復:
有人知道將Nuxt JS SSR應用部署到Google Cloud App Engine的正確app.yaml配置嗎?
我復制了你的案例,并使用你提供的app.yaml配置在App Engine中部署了Nuxt JS應用程式的基本教程。兩個配置都在作業,甚至我把instance_class從F2減少到F1,它仍然作業良好。
到目前為止,nodejs的推薦版本是nodejs14,但即使版本是nodejs10,該應用程式仍然可以在App Engine Standard中運行。env_variables是可選的,你可以在你的app.yaml檔案中定義環境變數,使其可用或在你的應用程式中使用它。
錯誤:
Error: 服務器 錯誤。
服務器遇到了一個錯誤,無法完成您的請求。
請 重試 在 30秒。
500錯誤或server錯誤很難找到原因。在Cloud Logging中查找日志,或者點擊這個鏈接,直接進入控制臺。確保你是在GAE應用程式 > 你的服務名稱 > App引擎版本。開始尋找訪問你的應用程式時出現的錯誤,并尋找錯誤原因描述。如果你沒有發現任何錯誤,請嘗試切換到所有日志。
- App Engine API
- 計算引擎API
Cloud Build API。
額外的故障排除,仔細檢查你的應用程式的監聽埠。
uj5u.com熱心網友回復:
請檢查應用程式的日志,以確保在GAE
上發生什么。
gcloud app logs tail
然后也試試我為nuxt SSR準備的yaml檔案:
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
uj5u.com熱心網友回復:
解決了這個問題,似乎是一個疏忽,在nuxt.config.js中指定了一個不同的服務器埠8000,而不是默認的。
通過查看使用的日志:
gcloud app logs tail
這個錯誤變得很明顯:
。 ? Nuxt Fatal Error
Error: listen EADDRNOTAVAIL: address not available *.*.*.*:8000.
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/317600.html
標籤:
