How does Firebase handle cross origin issues?

99封情书 提交于 2019-11-26 18:18:43

问题


Looking through the Firebase FAQ I can't see how cross domain issues are handled. Obviously, we don't want to serve on the Firebase domain, is it CORS, hidden iFrame, other? Would we need to create a sub-domain that points at the IP of the sharing server?


回答1:


Let me answer this question in two parts, as there are multiple ways to communicate with the Firebase Servers.

  • Firebase JavaScript Client - The Firebase Javascript Client maintains a real-time bidirectional connection to the server. Under the covers, this uses WebSockets whenever possible (which have no limitations with regard to cross-origin connections) and falls back to hidden-iframe-based jsonp long-polling on older browsers (which sidesteps cross-origin issues by only doing requests).
  • Firebase REST API - You can also get / set data from Firebase using the REST API, which uses CORS to allow cross-origin requests.

So in summary, it should "just work" and you don't need to do anything special.



来源:https://stackoverflow.com/questions/10710635/how-does-firebase-handle-cross-origin-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!