Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Firebase handle cross origin issues?

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?

like image 257
Thomas the Tank Engine Avatar asked May 22 '12 21:05

Thomas the Tank Engine


People also ask

What is the difference between onCall http callable and onRequest HTTP request functions?

onRequest creates a standard API endpoint, and you'll use whatever methods your client-side code normally uses to make. HTTP requests to interact with them. onCall creates a callable. Once you get used to them, onCall is less effort to write, but you don't have all the flexibility you might be used to.

How do I fix my Cors Express?

To solve this error, we need to add the CORS header to the server and give https://www.section.io access to the server response. Include the following in your index. js file. const cors = require('cors'); app.

What are firebase cloud functions?

Cloud Functions for Firebase is a serverless framework that lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your JavaScript or TypeScript code is stored in Google's cloud and runs in a managed environment.


1 Answers

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.

like image 158
Michael Lehenbauer Avatar answered Oct 12 '22 10:10

Michael Lehenbauer