Search code examples
firebasegoogle-cloud-platformgoogle-cloud-functionsfirebase-hosting

Firebase hosting connect to cloud function in *europe-west1*


I have an api set up on Google Cloud Functions (https://europe-west1-myproject-name.cloudfunctions.net/api/v1/ical.ics). This works well, but I wish to set up a "friendly" domain name for the api. :)

According to Googles documentation this is seems easy, but it does not seem to work for cloud functions outside the USA, eg. europe-west1.

I have updated the firebase.json file with the below code according to documentation.

  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/api/**",
        "function": "api"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }

When accessing https://myproject-name.web.app/api/v1/ical.ics I get redirected to https://us-central1-myproject-name.cloudfunctions.net/api/api/v1/cal.ics with error 403 and the below error message.

Error: Forbidden
Your client does not have permission to get URL /api/api/ical.ics from this server.

I must be overlooking something really basic here, since this seems like a really easy operation? :)

Kind regards /K


Solution

  • As stated in the documentation (see blue text block):

    If you are using HTTP functions to serve dynamic content for Firebase Hosting, you must use us-central1.


    You will also find a similar warning in the doc you refer to in your question about "Serve dynamic content and host microservices with Cloud Functions" (See blue text block as well):

    Firebase Hosting supports Cloud Functions in us-central1 only.