[英]How to deploy frontend and backend at the same time to App Engine?
目前,我有兩個不同的包 - 一個帶有我的 Java Web 應用程序(API 等)的 WAR 文件和一個 Angular 8 dist zip 文件。 我想要么部署到同一個應用引擎實例,要么部署到單獨的應用引擎實例。
如何將它們都部署到同一個應用引擎實例並仍然集成它們?
將它們都部署到同一個實例是否是一種好習慣,還是應該將它們分開?
如果我將它們部署到單獨的實例 - 我如何將它們指向另一個並避免 CORS 問題?
我不建議您將兩者部署在同一個實例上。 為什么? 因為,如果你想更新你的前端,例如,更新一個 CSS 或一個類型問題,你必須為此重新部署你的完整應用程序。
順便說一下,我建議您部署 2 個不同的實例。 前端名稱實例的前面,以及默認后端實例的后面。
您必須自定義 app.yaml 文件。 對於前端,只提供靜態文件,我使用這個文件
service: frontend
runtime: python37
handlers:
# Routing for bundles to serve directly
- url: /((?:(?:(?:inline|main|runtime|common|polyfills|styles|vendor)\.[a-z0-9]+\.js)|(?:[0-9]+\.[a-z0-9]+\.js)))
secure: always
redirect_http_response_code: 301
static_files: dist/\1
upload: dist/.*
# Routing for a prod styles.bundle.css to serve directly
- url: /(styles\.[a-z0-9]+\.css)
secure: always
redirect_http_response_code: 301
static_files: dist/\1
upload: dist/.*
# Routing for typedoc, assets and favicon.ico to serve directly
- url: /((?:assets|docs)/.*|favicon\.ico)
secure: always
redirect_http_response_code: 301
static_files: dist/\1
upload: dist/.*
# Any other requests are routed to index.html for angular to handle so we don't need hash URLs
- url: /.*
secure: always
redirect_http_response_code: 301
static_files: dist/index.html
upload: dist/index\.html
expiration: 0s
http_headers:
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: DENY
/static 目錄中僅提供靜態資源。 沒有實例產生,沒有成本。
注意:它也是一個有角度的應用程序,我在文件中使用了 python 運行時。 沒有影響,使用你想要的,它只是靜態資源服務!
支持是標准的並且特定於您的應用程序。 如果您正確設置了處理程序,則不應出現 cors 問題。
如果不是這種情況,請告訴我,我們將檢查您的配置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.