Routing between App Engine Standard Environment and Flexible Environment projects in production

123 Views Asked by At

I have two App Engine projects in Go that comprise a single user-facing app. One project is a Standard Environment project and has the bulk of the functionality and also serves the React frontend static bundle. The second project is a Flexible Environment project and serves a specific purpose of communicating with and transferring large files to a third-party API (it is a Flexible Environment project b/c we ran into size limitations using urlfetch).

Now that I am deploying the app, I am running into a problem with api requests from the frontend. In development, our frontend node server would proxy requests, e.g. /api/project and /api/user to the appropriate App Engine services running on different ports, but in production, my standard environment project is at something like https://my-project-std.appspot.com, and the flexible env project is at something like https://my-project-flex.appspot.com.

I use a dispatch.yaml file with the std env project to route api requests (e.g. /api/project and /api/user) to the appropriate service, but am not sure the best way to route requests that should go to the flexible environment service (e.g. /api/model). Should I route them through the std env project and redirect? setup a reverse proxy? some other approach?

Thanks!

2

There are 2 best solutions below

1
On

What does your dispatch.yaml & yaml for your services look like?

Did you mean that you have 2 services in the same project (not 2 separate projects)?

If so you can do this

https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed

https://[SERVICE_ID]-dot-[MY_PROJECT_ID].appspot.com

0
On

I went with a reverse proxy approach, and it is now behaving as I'd hoped. This blog post was very helpful in arriving at a solution https://blog.semanticart.com/2013/11/11/a-proper-api-proxy-written-in-go/