11
votes

We have an AppEngine app with that we would like to use with Google Endpoints. We need to support a web client as well as mobile clients which is what makes Endpoints attractive to us since we can easily generate Android and iOS client APIs.

The problem is that cloud endpoints currently don't support custom domains, so our web client cannot directly communicate with the endpoints (the mobile clients do not have this issue).

Here is what we've tried already:

  • CORS requests from the client to the appspot.com domain. The problem with this is since our request do not meet the requirements for simple CORS (custom headers, cookies, etc.), a preflight request must be sent with every request, which slows everything down

  • Client makes request to our custom domain which in turn makes a request to the appspot endpoint. Again, the extra request is not good for performance

  • We've also tried setting up a duplicate Jersey REST API just for the web client. We double annotate all our methods (once for Cloud Endpoints and once for Jersey) and the web client accesses the Jersey API and the mobile clients access the Endpoints API. This works pretty well except that Jersey and Endpoints use different exceptions. So if we want to throw a 404 Endpoints exception that will mess up the Jersey response and vice versa.

Are there any other options? We want to use the power of Endpoints for generating mobile clients but also get around the custom domain limitation for the web client.

3
This appears to still be an issue. You can star it if you want to follow developers complaining into a vacuum. code.google.com/p/googleappengine/issues/detail?id=9384 – TrophyGeek

3 Answers

2
votes

Google Cloud Endpoints 2.0 now supports custom domains. If you are using Google Cloud Endpoints 1.0 you can migrate by doing the following:

  • Update your dependency to use the new artifact. In Maven, this looks something like below:

    com.google.endpoints endpoints-framework 2.0.0-beta.8

  • Remove the legacy dependency, which is the appengine-endpoints artifact.

  • Update the API entry point in your project web.xml file:

    • Rename all occurrences of SystemServiceServlet to EndpointsServlet.
    • Replace all occurences of the path /_ah/spi/* to the new required path /_ah/api/*

See:

https://cloud.google.com/appengine/docs/java/endpoints/migrating

https://code.google.com/p/googleappengine/issues/detail?id=9384

9
votes

We ended up ditching Cloud Endpoints entirely and went with a pure Jersey REST API instead.

To deal with our need to generate mobile clients for the API, we annotated our API with Swagger. As an added bonus, Swagger seems to support more client generation than Cloud Endpoints and also makes it relatively easy to setup your own client generation from a template if your target language isn't directly supported.

Jersey + Swagger was not as easy to setup as Cloud Endpoints, but it is more customizable and allowed us to get around the custom domain restriction imposed by Cloud Endpoints.

1
votes

Easiest solution is to use reverse proxy. For example if your application is http://myapp.appspot.com, create simple html page on http://myapp.com and redirect to http://myapp.appspot.com using javascript.

Index.html on http://myapp.com.

<html>
   <head>
      <script>
          windows.location = http://myapp.appspot.com;
      </script> 
  </head>
  <body></body>
</html>  

It has one more advantage: if you put your proxy page on another hosting (not appspot.com) your application ( http://myapp.appspot.com ) will be accessible from China.