Valentin Coudert
Valentin Coudert

Reputation: 1939

Google App Engine routing with dispatch.yaml

I try to deploy a web app on my sandbox GCP project where there is already an app deployed. So I'm trying to play with the path to have the two web apps deployed at the same time.

My dispatch looks like this

dispatch:

- url: "*/wc/api/.*"
  service: wc-api

- url: "*/wc/.*"
  service: wc-front


- url: "*/.*"
  service: default

When I do so, all my calls to mysandbox.appspot.com/wc/ gets redirected to my default service and I don't understand why (I can see the calls in the logs of the default service).

If this helps, here is the app.yaml of my wc-front service.

runtime: python27
api_version: 1
threadsafe: yes
service: wc-front

default_expiration: "10m"

handlers:
- url: /wc/.*
  script: app.APP
  login: required
  secure: always

Do you see any error in this ?

(Calling directly wc-front-dot-mysandbox.appspot.com/wc/ returns the typical App Engine 404 error)

Thanks

Upvotes: 4

Views: 11468

Answers (2)

Valentin Coudert
Valentin Coudert

Reputation: 1939

It appears the problem was coming from the .* notation. This should only be used for the very general */.* rule.

My new - working - dispatch

dispatch:

- url: "*/wc/api/*"
  service: wc-api

- url: "*/wc/*"
  service: wc-front


- url: "*/.*"
  service: default

Upvotes: 4

gso_gabriel
gso_gabriel

Reputation: 4670

Yes, indeed, you need to configure your dispatch.yaml file, for App Engine to route your application based on the URL that you set there. It seems that your service: default it's getting all URLs and redirecting them to the service set there.

Considering that, I would recommend you to take a look at the official documentation about configuring the dispatch.yaml file - you can get some better ideas on how to configure it - and this other post from the Community, where another user has a similar use case as yours, that I believe should help you.

Let me know if the information helped you!

Upvotes: 1

Related Questions