'Can Firestore JS SDK onSnapshot listeners work over an http proxy?

I use the firestore js sdk in my web app, and faced a problem: some of my users are behind a firewall that blocks firebase urls (https://firebase.googleapis.com/, https://firestore.googleapis.com/, etc ) that the sdk talks to.

I plan to solve it by adding a service worker to intercept all requests to these urls, then forward them to my own server, which will then pass the requests to the firebase urls, and pass back the responses.

I imagine it could work, but I'm not sure if onSnapshot listeners will work too. I don't know the mechanism of the onSnapshot listeners, but I imagine WebSockets or gRPC are involved, but when I look at the devTools, I didn't see any WebSockets or gRPC traffic when I trigger the listener.

In any case, I want to know if my service worker + reverse proxy approach would work. Thanks!



Solution 1:[1]

You should try to use a proxy server, take a look at this page:

https://faun.pub/firebase-accessing-firestore-and-firebase-through-a-proxy-server-c6c6029cddb1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pablo