简体   繁体   English

如何在本地Google App Engine的非默认模块上访问Google Cloud Endpoints?

[英]How to access Google Cloud Endpoints on non-default module of local Google App Engine?

I'm developing a Google App Engine app with several modules. 我正在开发一个包含多个模块的Google App Engine应用程序。 Back-end APIs utilize Google Cloud Endpoints. 后端API使用Google Cloud Endpoints。 When I run the GAE server locally even though I load the APIs from my admin module (localhost:9090) after the client is loaded it tries to make the calls to the default module port (localhost:8080). 当我在本地运行GAE服务器时,即使我在加载客户端后从我的管理模块(localhost:9090)加载API,它也会尝试调用默认模块端口(localhost:8080)。 On remote GAE instance everything works just fine. 在远程GAE实例上一切正常。 What can be the reason or workaround for that? 可能是什么原因或解决方法?

The code is: 代码是:

function init() {
  var loadCallback = function () {
    gapi.client.adminapi.mymethod(12345).then(alert(Woohoo!));
  };

  var apiRoot = '//' + window.location.host + '/_ah/api';
  gapi.client.load('adminapi', 'v1', loadCallback, apiRoot);
}

Okay, the only answer that I've found and that worked as a workaround for non-default module in local GAE was described here: https://code.google.com/p/google-api-javascript-client/issues/detail?id=147 好的,我找到的唯一答案是本地GAE中非默认模块的解决方法: https : //code.google.com/p/google-api-javascript-client/issues/细节?ID = 147

  1. Open localhost:8090/_ah/api/discovery/v1/apis/adminapi/v1/rest 打开localhost:8090 / _ah / api / discovery / v1 / apis / adminapi / v1 / rest
  2. Download JSON 下载JSON
  3. Update List baseUrl and rootUrl to contain the right port (8090 in my case) 更新列表baseUrl和rootUrl以包含正确的端口(在我的情况下为8090)
  4. Pass updated JSON in gapi.client.load function on client instead of name of the API 在客户端上的gapi.client.load函数中传递更新的JSON而不是API的名称

Alternative: Add to @Api annotated Java class: root = " http://localhost:8090/_ah/api ", backendRoot = " http://localhost:8090/_ah/spi ", 替代方案:添加到@Api带注释的Java类:root =“ http://localhost:8090/_ah/api ”,backendRoot =“ http://localhost:8090/_ah/spi ”,

The only moment in these 2 approaches: I should not commit these changes as these URLs are surely not meant for production. 这两种方法中唯一的一刻:我不应该提交这些更改,因为这些URL肯定不适合生产。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google App Engine云端点:OAuth2无法正常工作。 无法加载API - Google App Engine Cloud Endpoints: OAuth2 won't work. Can't load api Google Cloud Secrets Manager 拒绝访问 App Engine 应用程序,但可与 Google Cloud Function 一起使用 - Google Cloud Secrets Manager denies access to App Engine application but works with Google Cloud Function 当我的JavaScript应用尝试访问我的Google Cloud端点时出现401错误 - 401 error when my javascript app tries to access my google cloud endpoints 如何从谷歌云应用引擎与外部 exe 程序通信? - How to communicate with an external exe program from an google cloud app engine? 如何将数据从应用程序引擎保存到数据存储谷歌云 javascript - How to save data from app engine to datastore google cloud javascript 如何使用oAuth2在服务器之间进行通信(Google Cloud Engine-> Google App Engine) - How to communicate between servers (Google Cloud Engine -> Google App Engine) using oAuth2 Google App Engine端点接受哪种URI格式? - Which URI format google app engine endpoints accepts? Google App Engine:修改 Cloud Run 环境 - Google App Engine: Modify Cloud Run Environment 如何将Google应用程序终结点与phonegap应用程序集成 - How Integrate Google app endpoints with a phonegap app Google Cloud Endpoints文档之间的差异以及我的应用程序中的哪些差异 - google cloud endpoints discrepancy between documentation, and what works in my app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM