Home > OS >  Calling Firebase https function from the server-side?
Calling Firebase https function from the server-side?

Time:02-02

Firebase https functions can be called from the client-side as the function call is provided by the client SDKs.

But can they be called from the server-side? I can't find any documentation or questions/answers about that.

Specifically, I'm using Next.js, and I'd like to call the https function during server-side rendering and pass the results via props to the client-side.

CodePudding user response:

Generic approach is describe here

For your SSR in Next.js use case you need some js http client like axios.

CodePudding user response:

Referencing previous threads, you would be better off building an HTTP function that you could call from your backend with an HTTP client. This is due to the problems in implementing the authentication required for HTTPS callable functions from the backend. This is what Maciek Sawicki mentioned.

Something else worth mentioning is that for other actions (like using Firestore or other Firebase services), there is the Firebase Admin SDK. The Admin SDK is meant to be used from the backend, and has different authentication requirements. Here is the reference if you would like to review what services you can use.

  •  Tags:  
  • Related