Home > OS >  Google App Engine: confused about routing with dispatch.yaml
Google App Engine: confused about routing with dispatch.yaml

Time:06-16

I'm trying to host my Spring Boot Angular app using GAE. My server app consists of a single module called back (the main class is called MyServerApplication).

I want all the URLs containing /api/ to end up in my Spring Boot endpoints. Here is my dispatch.yaml file:

dispatch:
  - url: "*/api/*"
    service: XXXXXXX

The XXXXXXX is what I'm having trouble with: I can't for the life of me understand what I'm supposed to put there. I tried writing back or my-server-application to no avail. I get the following error:

Updating config [dispatch]...failed.
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: The request contained an invalid argument.
- '@type': type.googleapis.com/google.rpc.BadRequest
  fieldViolations:
  - description: Service 'my-server-application' does not exist.
    field: dispatch_rules

As you can see my general understanding of web hosting and of GCloud/GAE is very low, so I'm probably not clear on what "service" means here, or I'm not even supposed to use this file for routing requests.

CodePudding user response:

When you use dispatch.yaml, the assumption is that your App has been broken down into smaller/individual apps and each of these Apps is viewed as a 'service'. For example a node App could be broken down into client (front-end) and back-end services. This architecture is typically referred to as microservices architecture

Each of these smaller App will have its own app.yaml file and the service name will be specified in the app.yaml file. You need to have a default service.

For a worked example and explanation, refer to my response on this Stack overflow question.

  • Related