Rewriting express endpoints in Cloud Functions to Firebase Hosting

Viewed 61

I am following this https://firebase.google.com/docs/hosting/functions (Use a Web Framework) in order to rewrite a url in the form of http://<mycustom_domain>/<api_name> on Firebase hosting to the respective Cloud Functions that use Express(). The endpoint for the API is https://<google_cloud_function_url>/app/<api_name>

This rewrite works:

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

What I want to do is rewrite http://<mycustom_domain>/app/<api_name> to https://<google_cloud_function_url>/app/<api_name>.

I have tried a few things such as

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

In the hope that whatever path comes after /app is passed onto express as the API name but this does not work and express returns something like Cannot GET /app/<api_name>

Any ideas how the rewrite should be written for this to work?

0 Answers
Related