We ran into an issue with corporate clients who are unable to authenticate with Firebase and read/write with Firestore as these requests to Google APIs were written on the front-end of our Next.js instance.
The error the clients see in their JS console:
Failed to load resource: net::ERR_TUNNEL_CONNECTION_FAILED
I imagine this is a strict same origin policy behind the corporate proxy, and we should move all firebase/firestore requests to the back-end, behind the /api in Next.js.
We can't ask each corporate client to whitelist *.googleapis.com cross-origin requests moving forward.
Am I correct in this assumption of next steps? If so, a large number of Firestore queries currently written on our front-end will need to move to the back-end, i.e.:
await db
.collection('users')
.doc(user.email)
.collection('starred')
.doc(user.id)
.set({ set: true });
Is there already an API library, Cloud same origin policy, or a Cloud Function to make this simpler then writing a whole new API for Firestore DB queries?