HTTP code 302 encountered when deploying on Google

2020-07-22 06:33发布

问题:

When developing for App Engine Endpoints in Java using the official documentation, after running endpoints.cmd with the appropriate parameters and deploying in GAE, the dev server shows the proper endpoints at http://localhost:8888/_ah/api/discovery/v1/apis, but accessing the explorer for the production version on GAE shows old endpoints at https://<my-app>.appspot.com/_ah/api/discovery/v1/apis.

The error was traced to the HTTP 302 (moved temporarily) code found in the Logs of the production app for access to /_ah/spi/BackendService.getApiConfigs. Until that clears (i.e., gives HTTP 200), Google's servers won't be able to serve the endpoint (See this comment).

回答1:

This error stems in part due to inconsistent documentation. While the official documentation's sample web.xml uses a <security-constraint> block, that of the sample tictactoe app does not.

If you are getting a HTTP 302 status code, check the following two things (from this post):

  1. in your .api file in WEB-INF, change http to https in the bns declaration,
  2. remove the <security-constraint> block from your web.xml.

The above worked for me; not sure what the security constraint bit was about. Maybe a GAE admin can improve this answer?