I have created a simple function for google assistant (dialogflow) for firebase function with the next structure:
functions/
node_module/
index.js
package-lock.json
package.json
firebase.json
How I can deploy this function (webhook) on Heroku for using it in Google actions for google home (dialogflow). The main problem with firebase is that the firebase doesn't allow sen HTTP request from functions in a free account.
You can only deploy code written for Cloud Functions to the Cloud Functions service itself. The code absolutely depends on the Cloud Functions scalable infrastructure to work the way that it does.
Related
I'm currently using json-server repo to emulate my back-end db and server for a prototype. To use/start json-server, I need to execute npm run json:server.
I've deployed my project to firebase but can't find a way to access a cmd or run that command from my own git-bash.
Is there any way of doing so or firebase doesn't allow to run commands on their end?
If you want to run small Node.js snippets on Firebase, have a look at the integration between Firebase Hosting and Cloud Functions.
Also see the Firebase documentation on what can you host on Firebase? and the overview documentation for running micro-services on Firebase Hosting and Cloud Functions.
I usually have my Firebase projects organized with a separate repo for the web app, manager portal, and cloud functions. Because the web app and manager portal use the same firebase project I keep the cloud functions in their own separate repo. So 3 different repos/projects using the same Firebase project.
I'm testing out how to use the Firebase Local Emulator Suite with this set up but it doesn't appear I can start the emulator for the cloud functions within my Cloud Function project, then use the emulator in my web app project for firestore and calling the functions, and then the same for my manager portal project. This will cause conflicts and cause them all to run on different ports and the functions project won't have access to the firestore emulator and the web app and manager won't have access to the functions emulator.
Is there a way to make this work? The only way I can see how is to have my manager app, web app, and functions all in the same project/repo...which I don't want to do for a bunch of reasons.
Currently I just set up a 2nd Staging project on firebase and use that for testing but would love to be able to do all of this locally. Any help is much appreciated.
I was just struggling with the same today and it turns out it is as simple as:
in your main project, start your emulators as usual with e.g. firebase emulators:start --only firestore
in your dependent projects, do not try to start the firestore emulator, but instead initialise the firebase config as follows:
import * as express from 'express'
import * as admin from 'firebase-admin'
import * as functions from 'firebase-functions'
admin.initializeApp(functions.config().firebase)
var db = admin.firestore()
if (process.env.NODE_ENV !== 'production') {
db.settings({
host: "localhost:8080",
ssl: false
})
}
You can use symbolic links in your project directories to create a "fake" functions directory. Then you can run a single instance of the emulator.
Running two instances of the emulator can cause several weird bugs as it is not recommended.
On windows:
mklink /D "R:\my-cloud-functions-proj\functions" "R:\my-web-app\functions"
When I first setup my firebase project and ran firebase init I didn't think i'd host a site. So I didn't check the hosting on setup.
And so i have an ios project with the following folder structure:
myproject:
- ios (xcode code)
- firebase
- functions
- index.js (i have cloud functions already deployed from here)
If I run firebase init again can i just select "hosting" so that a public folder is added without overwriting everything in the functions folder?
You can tell the CLI to only initialize hosting with:
firebase init hosting
That way your other settings will remain unmodified.
I have created a Firebase Function to server side render my website for SEO purposes.
However now when I use firebase serve or firebase serve --except functions the function is still triggered.
This means the only way I can test is by deploying and updating my https function.
Is there a way to test locally without triggering my function?
You can serve functions locally with the command below;
firebase serve --only functions
This would serve your functions from localhost:5000. If you would like to serve this local version you can also use NGROK and test it with your front-end.
I am following this doc to try to debug my firebase cloud function: https://cloud.google.com/functions/docs/monitoring/debugging
First of all the
The require line given in the doc was wrong so I changed it to this to make it compile:
require('#google-cloud/debug-agent').start();
Also after implementing this and deploying the functions using firebase deploy --only functions there is no code in stack drive debug view. Any idea how to make this work?
Thanks :)
Currently, Cloud Functions for Firebase do not share their code with Stackdriver automatically. You'll need to source your code via Github, Bitbucket, or a Google Cloud Source Repository.
While debugging Cloud Functions for Firebase please refer to our documentation. We'll make sure to note any differences between the environments.