GoogleFirebasehttpsCallablefundraiser::ERR_NAME_NOT_RESOLVED
I encountered net::ERR_NAME_NOT_RESOLVED when calling my firebase project's API.I tried using multiple devices, two internet connections, a VPN, Linux, macOS, Windows 11 to rule out any errors caused by my device.When navigating to an API link on a browser, it doesn't time out and gives me a response.The problem seems to be when using the httpsCallable function provided by Firebase.Aside from navigating to it in a browser, there is no log for called functions on firebase.
Here is my code:
const functions=firebase.functions
console.log(functions)
const loginWithCode=httpsCallable(functions, 'loginWithCode')
loginWithCode(loginPayload)
.then((result)=> {
console.log(result)
})
.catch((error)=> {
console.log("ERROR CAUGHT HERE")
console.log(error)
});
My browser console output:
service.ts:206 POST https://us-central1-"crowd-pleaser-75fd7",.cloudfunctions.net/loginWithCode net::ERR_NAME_NOT_RESOLVED
App.tsx:79 ERROR CAUGHT HERE
App.tsx:80 FirebaseError: internal
The result of entering the link directly in the firebase web interface:
{"error":{"message":"Bad Request","status" span>:"INVALID_ARGUMENT"}}
Is there something I'm missing that could be causing this problem? I have searched the internet and looked for answers on StackOverflow, but none of the solutions provided have worked.the way to implement it is here done in the Firebase archive
EDIT: The format of the link my post request is sent to seems odd.Maybe this could be the problem? I don't understand why it's formatted that way.
uj5u.com enthusiastic netizens replied:
I found a solution to my problem.My guess in the edit is correct, the URL to which httpsCallable sends the post request is malformed.I'm not sure why it's formatted this way, however, a quick fix is to set the customDomain class property of the object returned by getFunctions to the correct one area.In my case this was done by doing:
functions.customDomain=functions.customDomain='https://us-central1-crowd-pleaser-75fd7.cloudfunctions.net'
The variable 'functions' in the above code is the class attribute returned by the getFunctions method provided by Firebase
font>uj5u.com enthusiastic netizens replied:
Things
While I'm no Firebase expert, the problem is that you're making a bad HTTP request usingloginWithCode(loginPayload)
, at least I can see yours There is nothing wrong with the code.
By the way, you are using:
const loginWithCode=httpsCallable(functions, 'loginWithCode')
instead of const loginWithCode=httpsCallable('addMessage')
Simple described here : Google FireBase Docs
Then, make a loginWithCode({ text: messageText })
Also, as you can see here: Google Firebase Docs:firebase.functions.HttpsCallable
You will be able to pass any type of data to the HttpsCallable function, so we end where we started : You made a bad HTTP request.
As stated in the HTTP answer, the error is: net::ERR_NAME_NOT_RESOLVED
This happens when a DNS request cannot be resolved, then the domain does not exist , so this all causes the HTTP request to not be sent because there is no route found on the internet to send it.
Question:
When decoding the url from which you make an HTTP request
service.ts:206 POST https://us-central1-"crowd-pleaser-75fd7",.cloudfunctions.net/loginWithCode net::ERR_NAME_NOT_RESOLVED
App.tsx:79 ERROR CAUGHT HERE
App.tsx:80 FirebaseError: internal
You will find that you are sending HTTP requests to:
https://us-central1-"crowd-pleaser-75fd7",.cloudfunctions.net/loginWithCode
As you can see, you will find that there is a problem when making HTTP requests: because you cannot
font>"crowd-pleaser-75fd7",
Enter the URL to Make an HTTP request.That's an errornet::ERR_NAME_NOT_RESOLVED
I'm not sure what exactly you're trying to do, but I think the correct URL for an HTTP request should be:
https://us-central1-crowd-pleaser-75fd7.cloudfunctions.net/loginWithCode
Using this URL, the HTTP request must at least pass.I suggest then check loginPayload
to fix this.
6 Comments