I have hosted my WEB APP in firebase. It consists of a WEB APP that calls a WCF Service also hosted in firebase.
The problem is that at the time of calling service, firebase returns 404 error.
The app and the service work perfectly in my local IIS, so it's not a code error.
I commented to them that the error that it gives me is that it does not find this page (404) when in fact I would be returning the result of my query.
https://recoveryerpwcf.firebaseapp.com/General.svc/Select?tabla=Compania&codigo=0&columnas=%5BCodigoAgrupado%5D%7C%7C%5BDescripcionAgrupada%5D&filtro=&columnasf=%5BDescripcionAgrupada%5D&top=999&_=1528745507843
Firebase Hosting can serve static assets, and (by connecting it to Cloud Functions) Node.js scripts.
There is no way to host a WCF service in Firebase.
Related
That's basically my question.
Is there any way to have a PWA accessible in a public cloud service and when the user install it, locally, it can access a local REST API server to retrieve information?
Thank you
I have a Firebase app with an App Check debug token implemented.
When I run my Cloud Functions using the Emulator they work fine.
But when I turn off the emulator and try to access the live deployed version from http://localhost:8080/ I get this console error:
POST http://localhost:5001/my-app/us-central1/getZohoDeskTicketsLoggedInUser net::ERR_CONNECTION_REFUSED
Why does this happen when calling the live version and not with the emulator?
There are no Firebase Cloud Function logs to provide because the functions never even fire.
Perhaps I need to white list the locahost domain somewhere?
When you deploy your web app to productions, you should use URL of deployed Cloud function to make your API requests instead of localhost which will lead to connection errors. You can additionally call connectFunctionsEmulator only when you are on localhost:
if (window.location.hostname === "localhost") {
connectFunctionsEmulator(...)
}
I have Cloud run function deployed on one different project than a webapp hosted on firebase.
In firebase documentation it provides a way to call Cloud Run containers, but I can only specify serviceId and that service is not running in the same project as firebase container, so if I try to deploy it any way I get error 400.
Error: HTTP Error: 400, Cloud Run service `service-name` does not exist in region `europe-north1` in this project.
I did not see a way to specify a project id in the rewrites config.
Is there a way to call for firebase projects to call Cloud run containers from a different project?
P.S. I am aware that I can call it over "regular" HTTPS however I would like to reduce the traffic and maybe even some billing.
I'm building web app with flutter web and I'm using firebase hosting to serve the web app.
The web app makes an API post request to the static IP of my aws ec2 instance to get a response
const String api = 'http://7.91.300.2411:8080/predict';
Map<String, String> upload = {'data1': _data1, 'data2': _data2};
var _body = jsonEncode(upload);
final Uri uri = Uri.parse(api);
http.Response response =
await http.post(uri, headers: _headers, body: _body);
When I run the app on development, like on my local machine, it works, I see the logs on my ec2 server saying the endpoint was hit/called, and then it runs successfully.
But when I now deployed this web app to firebase hosting, the endpoint never gets hit/called, is as if the http post request was not made.
I've upgraded my firebase plan to blaze, yet it's still not working. I also enable cors on my ec2 instance.
Something I taught could solve the problem, was to edit the firebase.json file, and add some config to enable firebase hosting allow calls to external apis, but I don't know how to go about it
Actually, Firebase Hosting does not make calls to external APIs. Firebase Hosting "serves both static and dynamic content to a global CDN (content delivery network)". In the case of a Flutter web app, Firebase Hosting serves the files that were generated in the /build/web directory of your project when you built the app for deployment (aka the app release bundle).
The only scenario I can see that could be considered as Firebase Hosting making calls to external APIs is if you pair Firebase Hosting with Cloud Functions or Cloud Run, which, when they are executed, call the external API. Strictly speaking, in this scenario, Firebase Hosting does not call an API but serves dynamic content that was generated via a call to an API.
If I'm not mistaking, by looking at your code, we can conclude that this scenario does not apply to your case. In your case, Firebase Hosting just hosts your Flutter app release bundle.
In your case, you are using the Dart http package in order to call the API from your web page/app. I don't see any reason why Firebase Hosting would prevent that: Your browser has downloaded the web page from Firebase Hosting and then the web page initiates, from your browser, a direct call to an API (without calling Firebase Hosting). So most probably the problem comes from something else.
I have three Firebase projects representing Development, Staging and Production environments hosted on Firebase hosting. Each environment utilizes its own deployed Firebase functions like so:
Dev function endpoint: https://us-central1-my-app-dev.cloudfunctions.net/someFunction
Staging function endpoint: https://us-central1-my-app-staging.cloudfunctions.net/someFunction
Production function endpoint: https://us-central1-my-app.cloudfunctions.net/someFunction
I can't figure out how the static, Firebase-hosted client React application should invoke these functions because the URI endpoints of each changes depending on which environment the code is executing from.
Ideally I could set environment-specific configuration for each Firebase Hosting environment; unfortunately the only way to do this in Firebase Hosting is from within Firebase Functions themselves.
How can I retrieve the environment-specific endpoint for each Firebase Function?
You have a couple options here.
First, you could just configure your React app any way you like. It's necessarily not a bad thing for each system component (backend, frontend) to have its own configuration.
Second, since you're using Firebase Hosting to serve your static content, you can also use it to serve your functions API endpoints. This means that both your static content and API endpoints are all served through the same hostname, which means you no longer have to specify the host when making a request. All the requests can be relative to that host. You can achieve this via Hosting rewrite rules.