How to deploy frontend and backend at the same time to App Engine?

fire :

Currently, I have two different packages - a WAR file with my Java web application (APIs, etc) and an Angular 8 dist zip file. I want to either deploy both to the same app engine instance or to separate app engine instances.

How do I deploy both of them to the same app engine instance and have them still be integrated?

Is it a good practice to deploy both of them to the same instance or should you have it separate?

If I deploy them to separate instances - how would I point one to the other and avoid CORS issues?

guillaume blaquiere :

I don't recommend you to deploy both on the same instance. Why? Because, if you want to update your front, for example, update a CSS or a type issue, you have to redeploy your full app only for this.

By the way I recommend you to deploy 2 different instances. The front on the frontend name instances, and the back on default backend instance.

You have to customize the app.yaml file. For the front end, for serving only static files, I use this file

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

Only static resourced are served in the /static directory. No instance spawn, no cost.

Note: It was also an angular App and I use python runtime in the file. No impact, use what you want, it's only static resources served!

The backed is standard and specific to your app. if you set correctly your handlers, you shouldn't have cors issue.

Let me know if it's not the case, we will review your configuration.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=422129&siteId=1