Firebase如何处理跨源问题? [英] How does Firebase handle cross origin issues?

查看:146
本文介绍了Firebase如何处理跨源问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

浏览 Firebase 常见问题我看不到跨域问题是如何处理的。显然,我们不想在Firebase域上投放,是否 CORS ,隐藏的iFrame,其他?我们是否需要创建一个指向共享服务器IP的子域?

解决方案

让我回答这个问题两个部分,因为有多种与Firebase服务器进行通信的方式。


  • Firebase JavaScript客户端 - Firebase Javascript客户端保持与服务器的实时双向连接。在封面之下,它尽可能使用WebSockets(对于跨源连接没有限制),并且回退到基于隐藏iframe的jsonp在旧浏览器上的long-polling(它只是通过请求来避免跨域问题) 。
  • Firebase REST API - 您也可以使用REST API从Firebase获取/设置数据,REST API使用CORS来允许跨源请求。 >


所以总的来说,它应该只是工作,你不需要做任何特别的事情。

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?

解决方案

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.

这篇关于Firebase如何处理跨源问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆