dispatch.yaml not routing

531 views
Skip to first unread message

Rajesh G

unread,
Mar 12, 2022, 1:43:46 AM3/12/22
to google-a...@googlegroups.com
Hi,
I created two simple services based on nodejs and hello-world sample.

I am trying to explore dispatch.yaml
My dispatch.yaml.
dispatch:
  # Send all listing traffic to the listing frontend.
- url: "*/prolisting/*"
  service: prolisting
- url: "*/prolisting"
  service: prolisting
- url: "*/*"
  service: default


'prolisting' service app.yaml
runtime: nodejs14
service: prolisting

default service app.yaml
runtime: nodejs14

I have uploaded to bgsample.appspot.com.
The default works: bgsample.appspot.com

However, the following URL does not work

As per the dispatch.yaml, it should route to prolisting service, but gives the following error
Cannot GET /prolisting

my repo:
https://github.com/rajesh99/bgsample
Cheers,
--
Support Team
Field Service Software on Google Cloud Platform and Mobile


Jofre Riba Sánchez

unread,
Mar 14, 2022, 12:04:48 PM3/14/22
to Google App Engine
Your app.js in the prolisting folder of the example repo does not have a handler for the /prolisting path. This is why express can't get the /prolisting [1].

Fix this by adding an additional handler for the path in app.js:

app.get('/prolisting', (req, res) => {

res.status(200).send('Hello, world prolisting!').end();
});

Note that when you dispatch with a path (i.e. /prolisting), the path is kept when calling the dispatched service. The dispatch rules do not remove the path.

Rajesh G

unread,
Mar 15, 2022, 6:42:51 AM3/15/22
to google-a...@googlegroups.com
Ok.  It works now.  Thanks

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/d77d5b82-4bcb-43ac-821f-91454007a310n%40googlegroups.com.

Rajesh G

unread,
Mar 17, 2022, 9:19:08 AM3/17/22
to google-a...@googlegroups.com
I am further continuing to explore deploying a gatsby project to appengine

I created an appengine service called 'gatsby', and I want to serve in the following manner

app.yaml: gatsby-standard folder in the github: https://github.com/rajesh99/bgsample

runtime: nodejs14
service: gatsby

handlers:
- url: /gatbsy
  static_files: public/index.html
  upload: public/index.html
- url: /gatsby/
  static_files: public/index.html
  upload: public/index.html
- url: /gatsby/(.*)
  static_files: public/\1
  upload: public/(.*)


The main project: default-standard folder in the github: https://github.com/rajesh99/bgsample
dispatch.yaml
dispatch:
  # Send all listing traffic to the listing frontend.
- url: "*/prolisting/*"
  service: prolisting
- url: "*/prolisting"
  service: prolisting
- url: "*/gatsby/*"
  service: gatsby
- url: "*/gatsby"
  service: gatsby


There are two issues
1st issue:
https://bgsample.appspot.com/gatsby - this does not work - why?

2nd issue:
https://bgsample.appspot.com/gatsby/ - Then click on 'A' link it works.
Now you do refresh, it does not work.  Following displays on the browser
"Error: Not Found
The requested URL /gatsby/a/ was not found on this server."

I used the following reference to serve gatsby static files

I have to say, I did not understand some parts of the app.yaml file.

Appreciate any help.

Cheers.

Rajesh G

unread,
Mar 21, 2022, 5:33:06 AM3/21/22
to google-a...@googlegroups.com
FYI,
I explored gatsby-express-plugin 
It does not have the above two issues.


See the corresponding github repository:  https://github.com/rajesh99/bgsample

Rajesh
Field Service Software on Google Cloud Platform and Mobile




image.gif
On Tue, Mar 15, 2022 at 4:11 PM Rajesh G <rajesh...@veersoftsolutions.com> wrote:
Ok.  It works now.  Thanks

image.gif
image.gif

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/d77d5b82-4bcb-43ac-821f-91454007a310n%40googlegroups.com.


--
Support Team
Field Service Software on Google Cloud Platform and Mobile




--
Support Team
Field Service Software on Google Cloud Platform and Mobile


sivara...@google.com

unread,
Mar 25, 2022, 3:55:37 PM3/25/22
to Google App Engine
Hi ,

The following app.yaml file should work with Gatsby using the handlers like 

handlers:

  - url: /
    static_files: public/index.html
    upload: public/index.html

  - url: /((.*\/)*[^\/]+\.[^\/]+)$
    static_files: public/\1
    upload: public/.*

  - url: /(.*)$
    static_files: public/\1/index.html
    upload: public/.*/index.html

I also found this article[1] which might be helpful for your scenario. You can also check our documentation[2] for app.yaml elements which might be a great way to start resolving the error.

If you still have issues, I would suggest to please do open a case with us using [3] with all the information and we will look into it deeply.

Thanks,

Sivaranjani,
Google Cloud Platform Support, Montreal

Reply all
Reply to author
Forward
0 new messages