Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Engine: Having a web module and a endpoint module

I would like to have a web and an endpoint module.

I have this working in my dev environment largely following https://github.com/GoogleCloudPlatform/appengine-modules-sample-java .

However I can't get this working when hosted inside app engine. If I make the web module the default, I can't route to the endpoint module via dispatch.xml. This is because endpoints (apparently) need to live at /_ah/api and its not possible to route this away from the default module.

The other alternative is putting the endpoint module as the default module, however I don't then know how to route everything but /_ah/api/ to the web module. It seems that you can't route /* away from the default module.

EDIT: Note I want to have both modules running off of the same custom domain.

EDIT2: Note this is single page app. The front end module is purely html, css and js, which I want to talk to the endpoint module on the same domain.

Any way to solve this?

like image 397
Alistair Avatar asked Aug 31 '26 22:08

Alistair


1 Answers

If the problem only resides in the routing, you can definitely have your default module with endpoints and a module 'website' for your frontend.

Then your dispatch file should look like that (python version, the Java one should be quite similar):

dispatch: 
- url: "*/_ah/*"
  module: default
- url: "*/*"
  module: website

The dispatch file apparently sets the routing with a top to bottom priority so each request targeting the endpoints */_ah/* will be routed to the default module and the rest will go on the website module.

However if you have CORS issues, you can check in the handler configuration for static files or had the proper headers directly in your page handler code.

like image 79
Anhuin Avatar answered Sep 03 '26 13:09

Anhuin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!