Connect Firebase Hosting to cloud function in "europe-west1"

I’m trying to set up a “friendly” domain name for my API, hosted on Google Cloud Functions in the europe-west1 region. I have updated the firebase.json file according to Googles documentation, but I get an error 403 when accessing the API via the “friendly” domain name. The following rewrites are included in my firebase.json file:

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

I’m getting the following error message:

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

I’m likely overlooking something basic, but I’m not sure what. Can someone help me troubleshoot?

The issue is caused by the rewrites in the firebase.json file. Specifically, the "source": "/api/**" rewrite is causing the API to redirect to /api/api/ical.ics, resulting in the 403 error. To fix this, remove the extra /api from the rewrite source, like so:

"rewrites": [
  {
    "source": "/**",
    "function": "api"
  },
  {
    "source": "**",
    "destination": "/index.html"
  }
]

This should allow the API to be accessed via the “friendly” domain name without encountering the 403 error.