Firebase can't authenticate after building electron app - javascript

I have a problem with Firebase, React and Electron. When I use my app in dev, I use the localhost to load with react-scripts start , so it's loading in http://localhost:3000. I use this url to load my app with Electron.
BUT when I am trying to go in production, I use the electron-builder. I build my app with react-script build, it's create the build folder, and for the electron app, I change the loading url for file://${path.join(__dirname, "../build/index.html" I use build -c.extraMetadata.main=build/electron.js. It's now loading perfectly. BUT When I try to authenticate nothing happen and in the console, it says :
code : auth/operation-is-not-supported-in-this-environnement
message : This operation is not supported in the environnement this is running on. "location.protocol" must be http, https or chrome extension and web storage must be enable
How I can resolve this ?
My hypothesis it's because I don't write the url of my app in Authorized domains in Firebase Sign in method, but there is no url for my app, it's local. Does I need to load a server to employ Firebase ?
I see a similar post but without answer

I think it's because the SDK thinks it's running from a Node.js server environment. Currently, OAuth sign in with popup or redirect is not supported in Electronjs. You would need to get an OAuth credential from an electron compatible library and use the signInWithCredential API.
Firebase is looking into supporting signInWithPopup/Redirect in this environment.

Related

Firebase AppCheck - web app not working in debug mode

I have setup Firebase AppCheck for my Web App and everything seemed to work fine. Now I would like to enable the debug mode when developing my app.
I followed the instructions in the official documentation but I keep getting random errors from the AppCheck module, and these prevent my app from accessing Firebase Storage:
...at Backend FirebaseError: AppCheck: Fetch server returned an HTTP
error status. HTTP status: 429. (appCheck/fetch-status-error).
Following the doc, this is the way I set AppCheck in debug mode - this is ran before everything else:
if(window.location.hostname == "localhost")
self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;
Again, when my app is not in debug mode it works just fine.
Note 1: that I am not enforcing AppCheck via the console, and that 100% of the requests are displayed as "Verified"
Note 2: googling for "Firebase error 429" shows many results referring to some quota being exceeded, something hardly possible for my dev environment (we are 2 devs and definitely not putting in any sort of load on the app)
Its a bug with the js library
https://github.com/firebase/firebase-js-sdk/issues/5052
You should be using environment variables to detect debugging mode or not.
Depending on your framework and setup, this could be a command that you set up in your serve/build commands or a local env file that contains a specific debug key.
There is another issue if your reCaptcha is set to use localhost as the documentation states:
Warning: Do not try to enable localhost debugging by adding localhost to reCAPTCHA’s allowed domains. Doing so would allow anyone to run your app from their local machines!

Build succeeded for heroku app but running into "Application Error"

When I checked the Heroku build logs, it showed this:
The requested API endpoint was not found. Are you using the right HTTP verb (i.e. GET vs. POST), and did you specify your intended version with the Accept header?
My app runs on React framework for front end, and I use the Firebase realtime database for my backend. The app runs fine on my local server but when I try to deploy on to Heroku I run into this error.
My guess is that you didn't set the environment variables, thus the base url for your request might be invalid. You can set them in Settings tab of your heroku application, under the Config Vars section.

How to handle backend API request for create-react-app bootstrapped app which is build and ran using "serve-s build" on AWS ec2?

I have create-react-app bootstrapped application which I build and then serve it to the static server using serve-s build. The React app is running on http://locahost:3000.
This app talks to my backend REST API(using java) which is running on http://locahost:8080.
Inside my React application, I have set axios.default.baseURL=http://localhost:8085/api.
Everything is fine on the localhost on my system. The React app talks to http://localhost:8085/api/xyz for CRUD operations and everything works great.
Now I have to deploy the project on AWS EC2 instance. The MySQL and REST API got deployed and rest API there is running on same instance on the port 8085 as http://locahost:8085. I have Apache server configured which sends the hostname(www.myxyzwebsite.com) to the http://locahost:3000 on the server. Everything is fine till now. The home page is visible on the browser.
Now, when the React app tries to communicate to the REST API from the browser, it is sending the request to the http://locahost:8085. Obviously, now the browser looks for some service running on port 8085 on my system and it couldn't find. Ideally, the request should go to the server with my hostname(www.myxyzwebsite.com/api/users/puspen). How to make this REST API call looks like an actual call like www.myxyzwebsite.com/users/pusp?
NOTE: Please note that this is not a server-side-rendered application.

Is there a way to deploy GSuite app in our own server and run on GSuite Market place? So that every one can use that

I Wanted to create GSuite app and deploy in my own server instead of deploying in google cloud. Is there a way to do it? It would be great if i get some solution for this.
Thanks in advance
You can't deploy G Suite apps/extensions to your own server - they must be published via Chrome Web Store and/or G Suite Marketplace.
What you can do when you publish your app, is to set it as private so that only users in your domain can see and install the app. See Step 4 on Create and publish custom Chrome apps & extensions page for more details. Obviously, the app must be published by a domain account - you don't get that option if you publish an app from your personal/Gmail account.

Creating a react-native app for IOS and I have created a Microsoft SQL server, how to connect these two?

I have an app built on react native and I want to connect to a database that i have made on the Microsoft SQL server. I have searched online and there are things like myssql but I still get errors with that. I followed this tutorial nodejs from the official Microsoft website, and it works with the nodejs and I use node to run it, but how can i use this in my react native project?
You can use AXIOS to make requests to your NodeJS Server
In Android you can access your localhost by the IP 10.0.2.2 (default proxy configured in your Android Virtual Device).
In iOS you can just use localhost
Remember to add the port assigned your NodeJS Server and the
protocol http
Example URL for Android: http://10.0.2.2:3000
You need to write back-end service code.I suggest you to use Asp.Net Web API .You can use Entity Framework.
Also you can use PHP,Java or Python...

Categories