0

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.

Eva
  • 99
  • 1
  • 7
  • 1
    I think you may need to read the docs to understand what a service is in the App Engine Context https://cloud.google.com/appengine/docs/standard/nodejs/configuration-files – Puteri Jun 13 '22 at 17:27

1 Answers1

3

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.

NoCommandLine
  • 5,044
  • 2
  • 4
  • 15
  • I see. My server is just one single app so it looks like I'm going in the wrong direction with `dispatch.yaml`. My goal right now is simply to reach one of my endpoints successfully (using Postman for instance) and I can't seem to do that. Shouldn't `[PROJECT_ID].[REGION].r.appspot.com/api/something` normally do the trick? – Eva Jun 15 '22 at 08:37
  • Edit: Not sure what I did, but I can reach my endpoint now, so it works! – Eva Jun 15 '22 at 11:05