Search code examples
javascriptfirebasegoogle-cloud-firestoregoogle-cloud-functions

How do I deploy my firebase functions into a specific region?


const functions = require('firebase-functions')
const admin = require('firebase-admin')
admin.initializeApp()

exports.sendChatMsgNotification = functions.region('europe-west1')
firestore
  .document('chats/{idChat}/messages/{idMessage}')
  .onCreate((snap, context) => {
    console.log('----------------start function--------------------')

I am trying to deploy my Firebase cloud function into europe-west1 region because the default is us-central1, but I am always getting errors.

Yes, I have already tried to follow the official documentation https://firebase.google.com/docs/functions/locations#android. I just have no idea how to apply it correctly. I have tried many times.

If someone can just show me how to apply the correct way using my code above, would be highly appreciated!


Solution

  • Before

    exports.sendChatMsgNotification = functions.region('europe-west1')
    firestore
    

    After (working)

    exports.sendChatMsgNotification = functions.region('europe-west1').
    firestore
    

    I was only missing a dot (.) before "firestore". Thanks @Jason Berryman for pointing it out!