1
votes

I am trying to set up a AppEngine flexible (go) backend/api server together with a static frontend.

Ideally i would like to completely decouple the api server from the frontend so was planning to serve all the static files from cloud storage. I have managed to set this up by serving the static files on a subdomain from cloud storage - however, this means that users have to visit the subdomain to retrieve the index.html file.

Does anyone know if it is possible (in e.g. app.yml - but couldnt find anything in the docs here) to get fetch index.html from cloud storage?

I.e. such that:

https://example.com would return index.html from cloud storage https://example.com/api is routed to my appengine service?

1
You can have the Go server proxy GCS, for instance: golang.org/pkg/net/http/httputil/#NewSingleHostReverseProxyPeter
Thanks, thats of course a solution, but the I would not get the cdn advantage of cloud storage and all requests will have to be handled by the server - but if there is no other way i guess i can do that for index at least yesCalcopedia
Actually, thinking more about it, this is a good solution, proxying index and having all links in index refer to files at a subdomainCalcopedia

1 Answers

0
votes

Simply set the "www" subdomain to be your index.html, then let your App Engine handle the request routing. Look into how dispatch.yaml works and you will see how to do it.

Basically, let App Engine route all your default traffic to your index.html and then do the routine specific subdomains to whatever API handlers you have setup.