Rewrite or redirect Firebase Function

That should work okay…

What’s import webconf pulling in? That’s not included in what you posted.

Another approach would be to use handle_path instead (which implicitly strips a prefix from a URL), give this a shot:

handle_path /api* {
	rewrite * /test_api{path}
	reverse_proxy https://region-project.cloudfunctions.net
}

Oh come to think of it, I think it’s likely because the upstream expects the Host to be set to your cloudfunctions domain:

reverse_proxy https://region-project.cloudfunctions.net {
	header_up Host region-project.cloudfunctions.net
}

By default, Caddy will pass through the domain from the original request (i.e. subdomain.domain.com or whatever) for the Host, and this likely breaks what Google wanted.