【问题标题】:Is it possible to connect from another domain to my App Engine with the Channel API是否可以使用 Channel API 从另一个域连接到我的 App Engine
【发布时间】:2012-06-08 02:54:17
【问题描述】:

我希望使用 Channel 从我的站点到 App Engine 的后端进行跨域通信。这可能吗?如果可以,怎么办?因为Javascript API中没有域参数

【问题讨论】:

    标签: javascript google-app-engine cross-domain channel-api


    【解决方案1】:

    是的,你可以……我自己在做。你不需要做任何花哨的事情,只需要包含来自 app-engine 应用程序域的 /_ah/channel/jsapi 脚本,它应该可以工作

    示例: 来自http://mysite.com/index.html

    <head>
        <script language="javascript" type="text/javascript" src="http://myapp.appspot.com/_ah/channel/jsapi"></script>
    </head>
    

    然后正常使用Channel API https://developers.google.com/appengine/docs/python/channel/javascript

    【讨论】:

    • 这个解决方案对我不起作用(GAE Python 1.7.0 开发)——还没有尝试过。我设法通过手动替换 BASE_URL 来使其正常工作:goog.appengine.Socket.BASE_URL = "http://localhost:8080/" + goog.appengine.Socket.BASE_URL;
    • @mohabitar 加载 /_ah/channel/jsapi 脚本后的第一件事
    • 这两种解决方案似乎都不起作用。 :-( 也许框架中的某些东西发生了变化?或者这个解决方案仍然有效?
    猜你喜欢
    • 2023-04-11
    • 2014-09-09
    • 1970-01-01
    • 2014-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多