简体   繁体   中英

Where should I put firebase-auth user signin and signup code?

I want to create a REST API using Node JS. Because of the REST API, I want that, all the Firebase operations must be performed on the server and then the result will be returned to the client. I don't want to add Firebase API on the client-side so that it cannot directly interact with the Firebase.

So, my doubt is where should I put user sign-in and signup code for better performance and security, client-side or server-side? What are the consequences that may arise if I put that code on a client-side or server-side? Can you explain to me the pros and cons of this?

Thank you.

Regarding performance, it will be better to place the sign-in and signup code in the client side of your application. If you decide to put them in the server, you will have not just one communication between the client and the Firebase server, but two: you will send a request to your server which will require to, then, send a request to the Firebase server. This also means that you will have two responses back.

It can be more secure, for sure, but with the added complexity of duplicating API code to do the signin and signup features, and losing performance in the middle. The Firebase APIs for user management are aimed at providing the signin and signup features without having a to use an own backend, and it works quite well that way.

Given this, I can think of one use case where you may require API duplication: if you need to store your users in Firebase to use one of the authentication methods and, at the same time, you want to store your users in a Relational Database stored in your own backend server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM