Reputation: 728
I have a Firebase Cloud Function setup with ExpressJS which I would like to call call from my app.
I could of course just do an http request but since there is an cloud_firestore package (dart/Flutter) I thought that would be the best way to go, guessing it would handle the authentication for me.
The endpoint is just an express app:
const app = express();
app.post('/message', async function (req:any, res: any) {
...
other code
...
}
In my Flutter app I do:
final HttpsCallable addMessage = new CloudFunctions(region: "us-central1")
.getHttpsCallable(functionName: 'api');
addMessage.call();
This will return a NOT_FOUND error, probably because I have to pass in the path for ExpressJS. But I have not a clue about how to do that.
Upvotes: 1
Views: 714
Reputation: 317467
The Firebase callable functions client library does not work with arbitrary HTTP endpoints. It's meant to work only with callable functions that you write according to the documentation.
If you have a standard HTTP endpoint, just use a regular HTTP client library for that.
If you want to pass Firebase Auth credentials along with the request, there are some examples of that in the Firebase Admin SDK documentation. (You use the Admin SDK to verify the credentials passed from the client app.)
Upvotes: 2