google-cloud-platformgoogle-cloud-functionsload-balancinggoogle-cloud-rungcp-load-balancer

Removing prefixes for NEG paths in GCP Load Balancer


Consider 3 Cloud Functions:

I have created a LoadBalancer with:

  1. URL mask /functions/<function>
  2. Removing prefix to /

So now, I can run the CloudFunctions as:

Thanks to point 2, the CloudFunction receives following path:

However, the /cf* part is not desired, because it was only used to determine which CloudFunction to launch. Is there a way to remove this so that the functions receive only the paths which are relevant to them?

The very same thing applies to our Cloud Run services where I would like to achieve the same thing.


Solution

  • If you're looking for some sort of switch or configuration for this, it doesn't exist. You're going to have to write code to parse the actual URL path and extract the data you want out of it, ignoring anything you don't find relevant to the rest of the function's behavior.