0

I have firebase hosting and functions in the same project, where the hosting rewrites certain url requests to the function. It has been working well.

But after changing the region from us-central1 to another region on the function, I am getting this error whenever I go to http://localhost:5000/getoptions

Function us-central1-app does not exist, valid triggers are: europe-west1-app

here is my rewrite code in firebase.json.

"rewrites": [
  {
    "source": "**",
    "function": "app"
  }
]

"rewrites": [
  {
    "source": "**",
    "function": "app"
  }
]

why isn't it showing the error? is there a way to specify redirect region too?

Abraham
  • 12,140
  • 4
  • 56
  • 92

3 Answers3

2

After trying much, I found that as of 2021, firebase hosting rewrites to functions work for us-central1 region only. It's in the docs

Firebase Hosting supports Cloud Functions in us-entral1 only

So I had to remove those rewrites and use the full URL https://europe-west1-[project name].cloudfunctions.net/app to the function whenever I wanted to use my APIs in the deployed function.

Abraham
  • 12,140
  • 4
  • 56
  • 92
  • Using the direct URL makes sense here as you are not serving webpages to users. For APIs direct URLs (or even callable functions) work perfectly. – Dharmaraj Jul 07 '21 at 11:08
  • 2
    Now you can keep your `rewrite` and add region. Eg. ``` { "source": "**", "function": "MyFunction", "region": "europe-west1" } ``` – Michel Hervé NGOUNOU Jun 23 '22 at 10:08
0

I had a different error, google search ended up with this answer.

Function us-central1-app does not exist, valid functions are:

In my case apparently I was using 'express' and installing it solved it.

npm install express
Bakavani
  • 101
  • 5
0

If your issue is different than region related changes you can use

firebase login --reauth

This Works for most issues

Abraham
  • 12,140
  • 4
  • 56
  • 92