1

I am a newbie front end developer with no backend experience so please be patient with me.

I currently have a stack utilizing React and Firebase. I would like to make API requests to external sources such as Etsy or Twitter. I cannot make the requests from the front end side (React) for two reasons:

  1. In order to do the GET request, a lot of APIs require you to get a key. If I do these API requests on the front end, I believe my key will be exposed.

  2. I will most likely get a CORS error.

So my question is, can I do API requests from the Firebase side so that all the API requests are done in the backend? If so, what component of Firebase would allow for this capability? If not, what do I need to add to my stack without having to implement an entire backend structure in order to do these API requests?

Thank you very much for your time!

jellington
  • 11
  • 4

1 Answers1

0

You can use Cloud Functions within Firebase to do this. You can have your choice of languages, node is available and probably makes sense given you are already using ReactJS.

For example, see this answer to a similar question. Note that on Spark plans, you are only permitted to make outbound calls to google services, but on paid plans you can access non-Google APIs.

The functions also have full access to your realtime/firestore database and cloud storage, if you are using those facilities.

robsiemb
  • 6,157
  • 7
  • 32
  • 46